-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTODO.py
61 lines (47 loc) · 1.5 KB
/
TODO.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
tasks = []
def add_task():
task_name = input("enter your task:")
due_date = input("enter due date:")
tasks.append({"name":task_name, "due_date": due_date, "completed": False})
def view_task():
print("To-Do List:")
for i, task in enumerate(tasks, start=1):
status = "Done" if task["completed"] else "Not Done"
print(f"{i}. {task['name']} - Due: {task['due_date']} - Status: {status}")
def mark_comp():
view_task()
task_index = int(input("enter the index of completed task:")) - 1
if 0 <= task_index < len(tasks):
tasks[task_index]['completed'] = True
print("Task marked as completed")
else:
print("invalid task index!")
def del_task():
view_task()
task_index = int(input("enter the index of the task to delete:")) - 1
if 0 <= task_index < len(tasks):
del tasks[task_index]
print("your task deleted successfully")
else :
print("invalid task index!")
while True:
print("\nMenu")
print("1. Add Task")
print("2. View Task")
print("3. Mark_completed")
print("4. Delete Task")
print("5. Exit")
choice = input("enter your choice: ")
if choice == "1":
add_task()
elif choice == "2":
view_task()
elif choice == "3":
mark_comp()
elif choice == "4":
del_task()
elif choice == "5":
print("Exiting the app.")
break
else:
print("please enter valid choice")