forked from laviii123/Btecky
-
Notifications
You must be signed in to change notification settings - Fork 0
/
To-Do List.py
47 lines (39 loc) · 1.19 KB
/
To-Do List.py
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
class ToDoList:
def __init__(self):
self.tasks = []
def add_task(self, task):
self.tasks.append(task)
def remove_task(self, task):
if task in self.tasks:
self.tasks.remove(task)
def display_tasks(self):
if not self.tasks:
print("No tasks in the to-do list.")
else:
print("To-Do List:")
for i, task in enumerate(self.tasks, 1):
print(f"{i}. {task}")
def main():
todo_list = ToDoList()
while True:
print("\nOptions:")
print("1. Add Task")
print("2. Remove Task")
print("3. Display Tasks")
print("4. Quit")
choice = input("Enter your choice: ")
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":
todo_list.display_tasks()
elif choice == "4":
print("Goodbye!")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()