Skip to content

Commit bb61907

Browse files
authored
Create TodoListCLI.py
1 parent f6667f2 commit bb61907

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

TodoListCLI.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
class TodoList:
2+
def __init__(self):
3+
self.tasks = []
4+
5+
def add_task(self, task):
6+
self.tasks.append(task)
7+
print("Task added:", task)
8+
9+
def show_tasks(self):
10+
print("Tasks:")
11+
for i, task in enumerate(self.tasks, start=1):
12+
print(f"{i}. {task}")
13+
14+
if __name__ == "__main__":
15+
todo_list = TodoList()
16+
17+
while True:
18+
print("\nOptions:")
19+
print("1. Add Task")
20+
print("2. Show Tasks")
21+
print("3. Exit")
22+
23+
choice = input("Select an option: ")
24+
25+
if choice == "1":
26+
task = input("Enter task: ")
27+
todo_list.add_task(task)
28+
elif choice == "2":
29+
todo_list.show_tasks()
30+
elif choice == "3":
31+
print("Exiting...")
32+
break
33+
else:
34+
print("Invalid choice")

0 commit comments

Comments
 (0)