-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTo_do.py
More file actions
80 lines (62 loc) · 2.24 KB
/
To_do.py
File metadata and controls
80 lines (62 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import time
from colorama import Fore,Style
dict_of_tasks = {}
def add_task():
name_to_add = input("Name of task: ").capitalize()
if name_to_add not in dict_of_tasks:
dict_of_tasks[name_to_add] = 'In Progress' #Creates a new dictionary entry
print("Task '" + name_to_add + "' added to To-Do list")
else:
print("Task already exists ")
def change_task_status():
name_to_change = input("Name of task: ").capitalize()
if name_to_change in dict_of_tasks:
dict_of_tasks[name_to_change] = 'Completed'
else:
print("Task not found")
def delete_task():
name_to_delete = input("Name of task: ").capitalize()
if name_to_delete in dict_of_tasks:
del dict_of_tasks[name_to_delete]
print("Task '"+name_to_delete+"' deleted from To-Do list")
else:
print("Task not found")
def reset_list():
dict_of_tasks.clear()
print("To-Do list has been reset")
def view_tasks():
if len(dict_of_tasks)>0:
print("\nNumber of tasks: "+ str(len(dict_of_tasks))+"\n")
for key in dict_of_tasks:
if dict_of_tasks[key] == "Completed":
print('- ' + Fore.GREEN + key + '\t\t' + dict_of_tasks[key] + Style.RESET_ALL)
else:
print('- ' + Fore.RED + key + '\t\t' + dict_of_tasks[key] + Style.RESET_ALL)
else:
print("You have an empty To-Do list")
print("\n~ Welcome to To-Do-List ~")
print("_________________________")
while True:
time.sleep(2)
print("\n 'A' Add task")
print(" 'C' Change task status")
print(" 'D' Delete task ")
print(" 'R' Reset tasks ")
print(" '.' View all tasks ")
print(" 'e' Exit To-Do list")
user_input = input("Enter a command: ").upper()
if user_input == 'A':
add_task()
elif user_input == 'C':
change_task_status()
elif user_input == 'D':
delete_task()
elif user_input == 'R':
reset_list()
elif user_input == '.':
view_tasks()
elif user_input == 'E':
print("\nThank you for using my To-Do list!!\n")
break
else:
print("\nInvalid Command\nPlease enter a valid command ")