-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathto-do-list.py
More file actions
59 lines (51 loc) · 1.14 KB
/
to-do-list.py
File metadata and controls
59 lines (51 loc) · 1.14 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
#To-do list app
#List
list = []
#Task
task = ""
#Index
index = 0
#Menu
def menu():
print("\n1-Add task")
print("2-Delete task")
print("3-Clear list")
print("4-Show list")
print("5-Exit")
#Function to add a task to the list
def addTask(task, list):
task = input("Enter the task: ")
list.append(task)
#Function to delete a task to the list
def deleteTask(index, list):
index = int(input("Enter the index of the task to delete: "))
index-=1
list.pop(index)
#Function to clear list
def clearList(list):
list.clear()
#Function to show the list
def showList(list):
print("\nTO-DO-LIST:")
if len(list) == 0:
print("Empty list\n")
for index,task in enumerate(list):
print(f"{index+1} - {task}")
#Main loop
while True:
menu()
option = int(input("Choose an option: "))
if option == 1:
addTask(task, list)
showList(list)
elif option == 2:
showList(list)
deleteTask(index, list)
elif option == 3:
clearList(list)
showList(list)
elif option == 4:
showList(list)
elif option == 5:
break
print("Program finished")