-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathtodolist.py
More file actions
61 lines (50 loc) · 1.7 KB
/
Copy pathtodolist.py
File metadata and controls
61 lines (50 loc) · 1.7 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
class ToDoList:
def __init__(self):
self.tasks = {}
def add_task(self, task):
self.tasks[task] = "Incomplete"
print(f'Task "{task}" added successfully!')
def remove_task(self, task):
if task in self.tasks:
del self.tasks[task]
print(f'Task "{task}" removed successfully!')
else:
print(f'Task "{task}" not found.')
def mark_as_complete(self, task):
if task in self.tasks:
self.tasks[task] = "Complete"
print(f'Task "{task}" marked as complete!')
else:
print(f'Task "{task}" not found.')
def display_tasks(self):
print("\nTo-Do List:")
for task, status in self.tasks.items():
print(f'[{status}] {task}')
print()
def main():
todo_list = ToDoList()
while True:
print("1. Add Task")
print("2. Remove Task")
print("3. Mark Task as Complete")
print("4. Display Tasks")
print("5. Exit")
choice = input("Enter your choice (1-5): ")
if choice == "1":
task = input("Enter the task: ")
todo_list.add_task(task)
elif choice == "2":
task = input("Enter the task to remove: ")
todo_list.remove_task(task)
elif choice == "3":
task = input("Enter the task to mark as complete: ")
todo_list.mark_as_complete(task)
elif choice == "4":
todo_list.display_tasks()
elif choice == "5":
print("Exiting the To-Do List app. Goodbye!")
break
else:
print("Invalid choice. Please enter a number between 1 and 5.")
if __name__ == "__main__":
main()