-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCLI app.py
More file actions
36 lines (31 loc) · 889 Bytes
/
Copy pathCLI app.py
File metadata and controls
36 lines (31 loc) · 889 Bytes
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
# simple todo app
tasks = []
def show_menu():
print("\n== TODO MENU ==")
print("1. Add Task")
print("2. View Tasks")
print("3. Delete Task")
print("4. Exit")
while True:
show_menu()
choice = input("choose an option (2-4): ")
if choice == "1":
task = input("write your task: ")
tasks.append(task)
print("task added successfuly!")
elif choice == "2":
print("\nyour tasks: ")
for i, task in enumerate(tasks, 1):
print(f"{i}. {task}")
elif choice == "3":
index = int(input("enter task number to delete: ")) - 1
if 0 <= index < len(tasks):
removed = tasks.pop(index)
print(f"removed: {removed}")
else:
print("invalid task number!")
elif choice == "4":
print("goodbye")
break
else:
print("invalid option")