-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_app.py
More file actions
33 lines (29 loc) · 809 Bytes
/
python_app.py
File metadata and controls
33 lines (29 loc) · 809 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
#!/usr/bin/env python3
tasks = []
def show_tasks():
for index, task in enumerate(tasks, start=1):
print(f"{index}. {task}")
def add_task(task):
tasks.append(task)
print(f"Added task: {task}")
def remove_task(index):
try:
removed = tasks.pop(index-1)
print(f"Removed task: {removed}")
except IndexError:
print("Task not found.")
# Simple CLI
while True:
action = input("Choose an action: show, add, remove, exit: ")
if action == "show":
show_tasks()
elif action == "add":
task = input("Enter a task: ")
add_task(task)
elif action == "remove":
index = int(input("Enter task number to remove: "))
remove_task(index)
elif action == "exit":
break
else:
print("Unknown action.")