Repository navigation
Expand file tree
/
Copy pathtasklistmanager.py
More file actions
72 lines (62 loc) · 2.07 KB
/
Copy pathtasklistmanager.py
File metadata and controls
72 lines (62 loc) · 2.07 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
#Program Title : Task List Manager*: Develop a Python program to manage a task list using lists and tuples, including adding, removing, updating, and sorting tasks.
#Name : Gaurav
#Roll No. : 19
#Branch : Electronics Engineering
#DOP : 19/02/2026 DOS : 26/02/2026
tasks = [] # List to store tasks
while True:
print("\nTask List Manager")
print("1. Add Task")
print("2. Remove Task")
print("3. Update Task")
print("4. View Tasks")
print("5. Sort Tasks")
print("6. Exit")
choice = int(input("Enter your choice: "))
# Add Task
if choice == 1:
task_name = input("Enter task name: ")
priority = input("Enter priority (High/Medium/Low): ")
task = (task_name, priority) # Task stored as tuple
tasks.append(task)
print("Task added successfully!")
# Remove Task
elif choice == 2:
task_name = input("Enter task name to remove: ")
for task in tasks:
if task[0] == task_name:
tasks.remove(task)
print("Task removed successfully!")
break
else:
print("Task not found.")
# Update Task
elif choice == 3:
task_name = input("Enter task name to update: ")
for i in range(len(tasks)):
if tasks[i][0] == task_name:
new_name = input("Enter new task name: ")
new_priority = input("Enter new priority: ")
tasks[i] = (new_name, new_priority)
print("Task updated successfully!")
break
else:
print("Task not found.")
# View Tasks
elif choice == 4:
if not tasks:
print("No tasks available.")
else:
print("\nTask List:")
for task in tasks:
print("Task:", task[0], "| Priority:", task[1])
# Sort Tasks
elif choice == 5:
tasks.sort()
print("Tasks sorted successfully!")
# Exit
elif choice == 6:
print("Exiting Task Manager...")
break
else:
print("Invalid choice. Try again.")