-
Notifications
You must be signed in to change notification settings - Fork 0
/
to-do.py
76 lines (58 loc) · 2.67 KB
/
to-do.py
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
def main():
tasks =[]
while True:
print("To-Do Task app options: \n")
print("1. Add Tasks")
print("2. Show complete task list.")
print("3. Mark Task as done.")
print("4. Delete a task")
print("5. Clear list.")
print("6. Exit")
choice = input("Enter your choice: ")
if choice=='1':
print()
n_tasks = int(input("How much tasks you want to add? "))
for n in range(n_tasks):
task = input("Enter your task: ")
tasks.append({"task": task, "done": False})
print("------------\nTasks added!")
print("------------")
elif choice=='2':
if len(tasks)==0:
print("You have no tasks as of now.")
else:
print("------------------------------------------------------------------\nTasks: ")
for index, task in enumerate(tasks):
status = "Done." if task["done"] else "Not done."
print(f"{index + 1}. {task['task']} - {status}")
print("------------------------------------------------------------------")
elif choice=='3':
task_index = int(input("Enter the task number: "))
if 0<=task_index<len(tasks):
tasks[task_index]["done"]=True
print("-----\nTask Marked as done.\n")
print("------------\n")
else:
print("------------\nSelected task is invalid!")
print("------------")
elif choice=='4':
print(tasks)
task_to_delete = int(input("Enter the task index you want to delete: "))
tasks.pop(task_to_delete - 1)
print("------------\nTask deleted successfully!")
print("------------")
elif choice=='5':
print("Do you genuinely want to delete all tasks?")
yesno = int(input("Enter 1 for yes and 2 for no: "))
if yesno ==2:
choice
elif yesno ==1:
tasks.clear()
print("-----------\nYour task list has been cleared./n Thanks")
print("------------")
elif choice=='6':
exit()
else:
print("Invalid choice selection. Please try again.")
if __name__ == "__main__":
main()