forked from werhereitacademy/Python_Modul_Week_3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweek_3_cs_qs_1.py
More file actions
82 lines (76 loc) · 2.72 KB
/
week_3_cs_qs_1.py
File metadata and controls
82 lines (76 loc) · 2.72 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#task manager
#
tasks = []
íd = 0
while True:
print("1/ Add task")
print("2/ Remove task")
print("3/ Show tasks")
print("4/ List tasks")
print("5/ Exit")
choice = input("Choose an option: ")
if choice == "1":
name = input("Enter task name: ")
status = input("Enter task status: ")
due_date = input("Enter task due date: ")
task = {
"id": id,
"name": name,
"status": status,
"due_date": due_date
}
tasks.append(task)
íd += 1
print("Task added.")
elif choice == "2":
task_id = int(input("Enter task ID to remove: "))
for task in tasks:
if task["id"] == task_id:
tasks.remove(task)
print("Task removed.")
break
else:
print("Task not found.")
elif choice == "3":
for task in tasks:
print(f"ID: {task['id']}, Name: {task['name']}, Status: {task['status']}, Due Date: {task['due_date']}")
print("Do you want to edit this task? (yes/no)")
edit_choice = input()
if edit_choice.lower() == "yes":
new_name = input("Enter new task name: ")
new_status = input("Enter new task status: ")
new_due_date = input("Enter new task due date: ")
task["name"] = new_name
task["status"] = new_status
task["due_date"] = new_due_date
print("Task updated.")
elif edit_choice.lower() == "no":
print("No changes made.")
else:
print("Invalid choice. No changes made.")
elif choice == "4":
print("List of tasks:")
print("1/ ID\t 2/ Name\t 3/ Status\t 4/ Due Date\t 5/ Comleted Tasks")
choiselist = input("Choose a task to list: ")
if choiselist == "1":
for task in tasks:
print(f"ID: {task['id']}, Name: {task['name']}")
elif choiselist == "2":
for task in tasks:
print(f"ID: {task['id']}, Name: {task['name']}")
elif choiselist == "3":
for task in tasks:
print(f"ID: {task['id']}, Status: {task['status']}")
elif choiselist == "4":
for task in tasks:
print(f"ID: {task['id']}, Due Date: {task['due_date']}")
elif choiselist == "5":
for task in tasks:
if task["status"].lower() == "completed":
print(f"ID: {task['id']}, Name: {task['name']}")
else:
print("Invalid choice.")
break
elif choice == "5":
print("Exiting the task manager.")
break