-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodo list.py
44 lines (39 loc) · 1.12 KB
/
todo list.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
#Functions
#Greets the User
def greeting():
name = input("What is your name? ")
print(f"Hello, {name}! \n")
#Asks user to add task
def add_task(tasks):
task = input("What task would you like to add? ")
tasks.append(task)
print(f"Task '{task}' has been added to your todo list.")
#Shows user current items in todo list
def view_list(tasks):
if not tasks:
print(" \nYour todo list is empty.")
else:
print(" \nHere is your current todo list:")
for i in tasks:
print(" - {} \n".format(i))
#The main program
def main():
tasks = []
greeting()
while True:
print("Please choose an option:")
print("1. Add a task")
print("2. View list")
print("3. Exit \n")
choice = input("Enter your choice (1, 2, or 3):")
if choice == "1":
add_task(tasks)
elif choice == "2":
view_list(tasks)
elif choice == "3":
print("Goodbye!")
break
else:
print("Invalid choice, please try again.")
#Initiates Programme
main()