Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Adolf-Philip authored Feb 14, 2023
1 parent 360799e commit 8ece00b
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions todo list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

#Functions

#Greets the User
def greeting():
name = input("What is your name? ")
print(f"Hello, {name}!")

#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("Your todo list is empty.")
else:
print("Here is your current todo list:")
for i in tasks:
print(" - {}".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")
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()

0 comments on commit 8ece00b

Please sign in to comment.