forked from Nagasathvik/Python-Programming-Internship
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlist1.py
More file actions
43 lines (36 loc) · 1.05 KB
/
Copy pathlist1.py
File metadata and controls
43 lines (36 loc) · 1.05 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
import json
import os
def display_menu():
print("Todo List Menu:")
print("1. Add task")
print("2. Remove task")
print("3. View tasks")
print("4. Exit")
def todolist():
tasks = []
while 1:
display_menu()
ch= input("Enter your choice btw 1 and 4: ")
if ch== "1":
task = input("Enter a new task: ")
tasks.append(task)
print("Task added.")
elif ch == "2":
task = input("Enter the task to remove: ")
if task in tasks:
tasks.remove(task)
print("Task removed.")
else:
print("Task not found.")
elif ch== "3":
print("Tasks are:")
if tasks:
for index ,task in enumerate(tasks,start=1):
print(f"{index}. {task}")
else:
print("no tasks added")
elif ch == "4":
break
else:
print("Invalid choice. Please try again.")
todolist()