forked from egrazm/python-task-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
30 lines (22 loc) · 685 Bytes
/
main.py
File metadata and controls
30 lines (22 loc) · 685 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
tasks = []
def add_task(title):
tasks.append({
"title": title,
"completed": False
})
def list_tasks():
for i, task in enumerate(tasks):
status = "✔" if task["completed"] else "✘"
print(f"{i}. {task['title']} [{status}]")
def complete_task(index):
if not isinstance(index, int):
print("Error: index must be an integer")
return
if index < 0:
print("Error: index cannot be negative")
return
if index >= len(tasks):
print("Error: index out of range")
return
tasks[index]["completed"] = True
print(f"Task '{tasks[index]['title']}' marked as completed.")