-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.py
More file actions
74 lines (67 loc) · 2.84 KB
/
Copy pathtodo.py
File metadata and controls
74 lines (67 loc) · 2.84 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
from os import name
class Task:
def __init__(self, name, due_date, priority):
self.name = name
self.due_date = due_date
self.priority = priority
self.completed = False
def __str__(self):
return f"{self.name} (Due: {self.due_date}, Priority: {self.priority})"
def mark_completed(self):
self.completed = True
print(f"Task {self.name} has been completed. Congrats!")
def edit_task(self, new_name, new_due_date, new_priority):
self.name = name
self.due_date = new_due_date
self.priority = new_priority
print(f"Task {self.name} has been edited.")
print("Welcome to the task manager:")
tasks = []
while True:
if not tasks:
print("You task list is empty. Add new tasks to get started")
while True:
name = input("Enter task name: ")
due_date = input("Enter due date: ")
priority = input("Enter priority: ")
task = Task(name, due_date, priority)
tasks.append(task)
print(f"Task {name} has been added to the list.")
if input("Do you want to add another task? (y/n): ") != "y":
break
else:
print("Your current tasks are:")
for task in tasks:
print(task)
if input("Do you want to add new tasks? (y/n): ") == "y":
while True:
name = input("Enter task name: ")
due_date = input("Enter due date: ")
priority = input("Enter the priority: ")
task = Task(name, due_date, priority)
tasks.append(task)
print(f"Task {name} has been added to the list.")
if input("Do you want to add another task? (y/n): ") != "y":
break
else:
inp = input("Wnat do you want to do: ")
match inp:
case "mark completed":
taskno = int(input("Enter task number: "))
tasks[taskno-1].mark_completed()
print(f"Congrats! You completed the task {tasks[taskno-1].name}")
tasks.pop(taskno-1)
case "edit task":
taskno = int(input("Enter task number: "))
new_name = input("Enter the new name for the task: ")
new_due_date = input("Enter the new due date for the task: ")
new_priority = input("Enter the new priority for the task:")
tasks[taskno-1].edit_task(new_name, new_due_date, new_priority)
case "view task":
taskno = int(input("Enter task number: "))
print(tasks[taskno-1])
case "exit":
break
case _:
print("Invalid input. Please try again.")
continue