-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodolist.py
43 lines (36 loc) · 1.18 KB
/
todolist.py
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
def addTasks(taskList, task):
taskNum = len(taskList) + 1
taskList[taskNum] = task
def deleteTasks(numDelete, taskList):
if numDelete in taskList:
del taskList[numDelete]
else:
print(f"Task number {numDelete} not found.")
def printTasks(taskList):
if not taskList:
print("No tasks available.")
else:
for task_id, task in taskList.items():
print(f"{task_id}: {task}")
taskList = {}
def main():
global taskList
answer = input("Type 'A' to add a task, 'D' to delete a task, 'V' to view task list, or 'Q' to exit. ").strip().upper()
if (answer == "A"):
task = input("Please enter your task: ")
addTasks(taskList, task)
printTasks(taskList)
elif (answer == 'D'):
printTasks(taskList)
numDelete = int(input("Please input the number of which task you would like to delete: "))
deleteTasks(numDelete, taskList)
printTasks(taskList)
elif (answer == 'V'):
printTasks(taskList)
elif (answer == 'Q'):
quit()
else:
print("Please enter a valid character.")
print("hello! welcome to the to do list manager.")
while True:
main()