-
Notifications
You must be signed in to change notification settings - Fork 48
/
To Do List
46 lines (41 loc) · 1.27 KB
/
To Do List
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
def display_menu():
print("To-Do List Menu:")
print("1. Add Task")
print("2. Remove Task")
print("3. View Tasks")
print("4. Exit")
def add_task(task_list):
task = input("Enter the task to add: ")
task_list.append(task)
print(f'Task "{task}" added!')
def remove_task(task_list):
view_tasks(task_list)
task_index = int(input("Enter the task number to remove: ")) - 1
if 0 <= task_index < len(task_list):
removed_task = task_list.pop(task_index)
print(f'Task "{removed_task}" removed!')
else:
print("Invalid task number.")
def view_tasks(task_list):
if not task_list:
print("No tasks in the list.")
else:
print("Your Tasks:")
for index, task in enumerate(task_list, start=1):
print(f"{index}. {task}")
def main():
task_list = []
while True:
display_menu()
choice = input("Choose an option (1-4): ")
if choice == '1':
add_task(task_list)
elif choice == '2':
remove_task(task_list)
elif choice == '3':
view_tasks(task_list)
elif choice == '4':
print("Goodbye!")
break
else:
print("Invalid choice. Please choose a number between 1 and 4.")