-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo.py
55 lines (48 loc) · 1.56 KB
/
todo.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Simple ToDo List Commandline App
# Written following https://www.youtube.com/watch?v=aEIHZDv_23U
# A quick and dirty ToDo app we can expand upon later
tasks = []
def addTask():
task = input("Please enter a task: ")
tasks.append(task)
print(f"The task '{task}' was added successfully.")
def showTasks():
if not tasks:
print("There are currently no tasks. \n")
else:
print("Current Tasks:")
for index, task in enumerate(tasks):
print(f"Task #{index}: {task}")
def deleteTask():
showTasks()
try:
taskToDelete = int(input("Please enter the index of the task to delete: "))
if index >= 0 and index < len(tasks):
tasks.pop(taskToDelete)
print(f"Task #{taskToDelete} was successfully removed.")
else:
print(f"Task #{taskToDelete} could not be found.")
except:
print("Invalid input")
if __name__ == "__main__":
print("Welcome to the to do list")
while True:
print("\n")
print("Please select an option:")
print("------------------------")
print("1. Add a new task")
print("2. Delete a task")
print("3. List tasks")
print("4. Quit")
choice = input("Enter your choice: ")
if(choice == "1"):
addTask()
elif(choice == "2"):
deleteTask()
elif(choice == "3"):
showTasks
elif(choice == "4"):
break
else:
print("Choice is invalid. Please try again.")
print("Goodbye. Thanks for using the app.")