-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTO-DO list
More file actions
61 lines (54 loc) · 1.62 KB
/
Copy pathTO-DO list
File metadata and controls
61 lines (54 loc) · 1.62 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
task = []
def show_menu():
print("\n=== To-Do List Menu ===")
print("1. View Tasks")
print("2. Add Task")
print("3. Mark Task as Done")
print("4. Delete Task")
print("5. Exit")
def view_tasks():
if not task:
print("No tasks to display.")
else:
for i, item in enumerate(task, 1):
status = "✅" if item['done'] else "❌"
print(f"{i}. {item['task']} [{status}]")
def add_task():
new_task = input("Enter task: ")
task.append({
'task':new_task,
'done':Fals e
})
print("Task added successfully!")
def mark_task_done():
view_tasks()
task_index = int(input("Enter the task number to mark as done: "))
if 1 <= task_index <= len(task): # Corrected the condition to include the last task
task[task_index-1]['done'] = True
print("Task marked as done!")
else:
print("Invalid task number.")
def delete_task():
view_tasks()
task_index = int(input("Enter the task number to delete: "))
if 1 <= task_index <= len(task): # Corrected the condition to include the last task
del task[task_index-1]
print("Task deleted successfully!")
else:
print("Invalid task number.")
while True:
show_menu()
choice = input("Enter your choice (1/2/3/4/5): ")
if choice == '1':
view_tasks()
elif choice == '2':
add_task()
elif choice == '3':
mark_task_done()
elif choice == '4':
delete_task()
elif choice == '5':
print("Exiting the program.")
break
else:
print("Invalid choice. Please select a valid option.")