-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path.py
More file actions
53 lines (44 loc) · 1.41 KB
/
.py
File metadata and controls
53 lines (44 loc) · 1.41 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
# to_do_list_app.py
class ToDoList:
def __init__(self):
self.tasks = []
def add_task(self, task):
self.tasks.append(task)
print(f"Task '{task}' added successfully!")
def remove_task(self, task):
if task in self.tasks:
self.tasks.remove(task)
print(f"Task '{task}' removed successfully!")
else:
print(f"Task '{task}' not found in the list.")
def view_tasks(self):
if not self.tasks:
print("Your to-do list is empty.")
else:
print("Your To-Do List:")
for idx, task in enumerate(self.tasks, start=1):
print(f"{idx}. {task}")
def main():
to_do_list = ToDoList()
while True:
print("\nTo-Do List App")
print("1. Add Task")
print("2. Remove Task")
print("3. View Tasks")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == '1':
task = input("Enter the task to add: ")
to_do_list.add_task(task)
elif choice == '2':
task = input("Enter the task to remove: ")
to_do_list.remove_task(task)
elif choice == '3':
to_do_list.view_tasks()
elif choice == '4':
print("Exiting the app. Goodbye!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()