-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo_manager.py
More file actions
66 lines (55 loc) · 1.57 KB
/
Copy pathtodo_manager.py
File metadata and controls
66 lines (55 loc) · 1.57 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
tasks = [
{"task": "Study Python", "status": "Pending"},
{"task": "Buy Milk", "status": "Done"}
]
# tasks = []
def show_tasks():
if not tasks:
print("No tasks yet!")
else:
print("\nYour To-Do List:")
for i, task in enumerate(tasks):
print(f"{i +1}. {task['task']} - {task['status']}")
def add_task():
task_name = input("Enter the task: ")
tasks.append({"task": task_name, "status": "Pending"})
print("Task added!")
def mark_done():
show_tasks()
task_no = int(input("Enter task number to mark as done: ")) - 1
if 0 <= task_no < len(tasks):
tasks[task_no]["status"] = "Done"
print("Task marked as done!")
else:
print("Invalid task number.")
def delete_task():
show_tasks()
task_no = int(input("Enter task number to delete: ")) - 1
if 0 <= task_no < len(tasks):
deleted = tasks.pop(task_no)
print(f"Deleted: {deleted['task']}")
else:
print("Invalid task number.")
def menu():
print("\n===== TO-DO MANAGER =====")
print("1. View Tasks")
print("2. Add Task")
print("3. Mark Task as Done")
print("4. Delete Task")
print("5. Exit")
while True:
menu()
choice = input("Choose an option (1-5): ")
if choice == "1":
show_tasks()
elif choice == "2":
add_task()
elif choice == "3":
mark_done()
elif choice == "4":
delete_task()
elif choice == "5":
print("Goodbye!")
break
else:
print("Invalid choice. Please try again.")