-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtodo.py
More file actions
44 lines (42 loc) · 1.84 KB
/
todo.py
File metadata and controls
44 lines (42 loc) · 1.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
def task():
tasks = [] # Initialize an empty list to store tasks
print("----WELCOME TO THE TASK MANAGEMENT APP----")
total_task = int(input("Enter how many tasks you want to add = "))
for i in range(1, total_task + 1):
task_name = input(f"Enter task {i} = ")
tasks.append(task_name)
print(f"Today's tasks are\n{tasks}")
while True:
try:
operation = int(input("Enter \n1-Add\n2-Update\n3-Delete\n4-View\n5-Exit/Stop\n"))
if operation == 1:
add = input("Enter task you want to add = ")
tasks.append(add)
print(f"Task '{add}' has been successfully added.")
elif operation == 2:
updated_val = input("Enter the task name you want to update = ")
if updated_val in tasks:
up = input("Enter new task = ")
ind = tasks.index(updated_val)
tasks[ind] = up
print(f"Updated task '{updated_val}' to '{up}'.")
else:
print("Task not found.")
elif operation == 3:
del_val = input("Which task you want to delete = ")
if del_val in tasks:
ind = tasks.index(del_val)
del tasks[ind]
print(f"Task '{del_val}' has been deleted.")
else:
print("Task not found.")
elif operation == 4:
print(f"Total tasks = {tasks}")
elif operation == 5:
print("Closing the program....")
break
else:
print("Invalid Input. Please enter a number from 1 to 5.")
except ValueError:
print("Invalid Input. Please enter a valid number.")
task()