-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathview_tasks.py
More file actions
34 lines (27 loc) · 875 Bytes
/
view_tasks.py
File metadata and controls
34 lines (27 loc) · 875 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
import json
import os
DATA_FILE = "data.json"
def load_data():
"""Load tasks from JSON file or return empty list wrapper."""
if os.path.exists(DATA_FILE):
with open(DATA_FILE, "r") as f:
return json.load(f)
return {"tasks": []}
def view_tasks():
"""Display all tasks neatly with ID, status, priority, description."""
data = load_data()
tasks = data.get("tasks", [])
if not tasks:
print("No tasks available.")
return
print("\n Task List")
print("-" * 50)
for task in tasks:
status = " Completed" if task.get("completed") else " Not Completed"
print("ID:", task.get("id"))
print("Description:", task.get("description"))
print("Priority:", task.get("priority"))
print("Status:", status)
print("-" * 50)
if __name__ == "__main__":
view_tasks()