#To_Do_List Project
try:
to_do_list = [] #adding empty list
print ("Welcome to the Simple To-Do List Manager!")
# Showing the menu options
def menu():
try:
print ("\nMenu:")
print ("1.View To-Do List \n2.Add Task \n3.Remove Task \n4.Exit\n")
global user
user = int(input("Please choose an option: 1, 2, 3, 4: "))
except ValueError:
print('Invalid input. Please choose a menu option: 1, 2, 3, 4')
menu()
# create the showing list function
def showing_list():
if to_do_list == []:
print ('To Do List is empty')
else:
i=0 #the position of the value in the list
for list_value in to_do_list:
i+=1
print (f"{i}. {list_value}")
print("\n")
# menu function
menu()
# view To_Do_List
while user !=0 or user == 0:
if user==1:
print("\nTo Do List:")
if to_do_list == []:
print ('To Do List is empty')
menu()
else:
showing_list()
menu()
# Add Task into To_Do_List
elif user == 2:
user_type = input("Enter a task description: ")
to_do_list.append(user_type)
print (f"Task '{user_type}' added to the to-do list.")
menu()
#Remove Task from To_Do_List
elif user == 3:
try:
print("\nTo Do List:")
#if list is empty print 'To Do List is empty'
showing_list()
if to_do_list == []:
menu()
# if not
else:
removelist = int(input("Enter the position of the task to remove: "))
if 1<= removelist <= len(to_do_list):
print (f"Task '{to_do_list[removelist-1]}' removed from the to-do list.")
to_do_list.pop(removelist-1)
menu()
else:
print('Invalid input. Please choose a menu option: 1, 2, 3, 4')
except ValueError:
print('Invalid input. Please choose a menu option: 1, 2, 3, 4')
#Enter '4' to exit the program
elif user == 4:
print ("Goodbye! Thank you for using the Simple To-Do List Manager.")
break
#when the user types different numbers, it will print "Please type 1, 2, 3, or 4"
else:
print ("Please choose a menu option: 1, 2, 3, 4")
menu()
#when the user types difference type, it will print 'Invalid input. Please choose a menu option: 1, 2, 3, 4'
except ValueError:
print('Invalid input. Please choose a menu option: 1, 2, 3, 4')
menu()