This repository was archived by the owner on Feb 15, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodolist.py
More file actions
69 lines (61 loc) · 1.91 KB
/
todolist.py
File metadata and controls
69 lines (61 loc) · 1.91 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
67
68
69
# Simple Terminal To Do List v1
# CAPS LOCK DAVE 8/26/2023
def display_menu():
"""Display the available commands."""
print("\nMENU:")
print("1. View To-Do List")
print("2. Add Item to To-Do List")
print("3. Remove Item from To-Do List")
print("4. Mark Item as Done")
print("5. Exit")
def view_tasks(tasks):
"""Display all the tasks."""
if not tasks:
print("To-Do List is empty!")
else:
print("\nTo-Do List:")
for idx, task in enumerate(tasks, 1):
print(f"{idx}. {task}")
def add_task(tasks):
"""Add a new task."""
task = input("Enter the new task: ")
tasks.append(task)
print(f"'{task}' has been added to the list.")
def remove_task(tasks):
"""Remove a task by its number."""
view_tasks(tasks)
task_num = int(input("Enter the number of the task to remove: "))
if 1 <= task_num <= len(tasks):
removed = tasks.pop(task_num-1)
print(f"'{removed}' has been removed from the list.")
else:
print("Invalid task number.")
def mark_done(tasks):
"""Mark a task as DONE."""
view_tasks(tasks)
task_num = int(input("Enter the number of the task to mark as done: "))
if 1 <= task_num <= len(tasks):
tasks[task_num-1] = f"DONE // {tasks[task_num-1]}"
print(f"Task {task_num} has been marked as done.")
else:
print("Invalid task number.")
def main():
tasks = []
while True:
display_menu()
choice = input("Enter your choice: ")
if choice == "1":
view_tasks(tasks)
elif choice == "2":
add_task(tasks)
elif choice == "3":
remove_task(tasks)
elif choice == "4":
mark_done(tasks)
elif choice == "5":
print("Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1-5.")
if __name__ == "__main__":
main()