In this program, you will be create code that allows the user to build and manage a list. It can be a “to do” list.
But there are so many other possibilities: -a bucket list -a gap year list -places you’d like to visit list -your desert island playlist
Let’s start by building your functions. In your code, place the functions ABOVE the code for your menu.
In the examples below, let’s assume that you have created a list called animals.
- view list – I’m giving you this code to get you started. This code is in a function and will tell if you if your list is blank OR display whatever is in your list:
def view_list():
if len(animals) == 0:
print("Your list is empty")
print ("But you can add something...")
time.sleep(1)
menu()
else:
print ("Here's a list of animals:")
for index, item in enumerate(animals):
print(index + 1, item)
time.sleep(2)
os.system("clear")
menu()
2. add to list – asks if you want to add something to the list. Put this code in a function and call the function in your menu. If your list is named “animals” then you would use:
newitem = input("add an animal")
animals.append(newitem)
#call the function that views your list.
3. delete from this – delete an item by typing the name as an input. Put this code in a function and call the function in your menu. If want to delete “frog” from the list then use this code:
def delete_from_list():
print ("Here's your list:")
for index, item in enumerate(animals):
print(index + 1, item)
time.sleep(2)
print("Enter the name of the item you want to delete")
item_name = input(" will be deleted.")
time.sleep(1)
todolist.remove(item_name)
print ("Here's your NEW to-do list:")
for index, item in enumerate(animals):
print(index + 1, item)
4. sort list – really fun – it alphabetizes your list. Put this code in a function and call the function in your menu.
animals.sort()
5. Now it’s time to build your menu. This should be built BELOW all of your functions.

HINTS for making this menu: 1. build it by making a series of print statements like: print (“1: view list”) 2. use if/elif statements to make the menu work, like this:
if choice == “1”: view_list() #this is the name of the function that calls the function view_list()
Requirements:
- setup your program to allow the user to do all the things on the menu above.
- choose something other than animals and don’t name your list animals. Because I did that in the examples and I want you to branch out.
- create functions for each item on the menu.
- call these functions when you want something to happen.
- have a menu like the example above.
- show them their list after they add an item to the list.
- comment at least five lines of code in your own words so I know that you understand what’s happening.
- use import time and time.sleep(number of seconds) to slow down the program to human speed.
Secrets to success:
- create a function for each item on the menu.
- to build your menu, use if/else statements to call each function. So if someone presses “1” to view the list then the view_list()function is called.