0% found this document useful (0 votes)
2 views3 pages

Python Questions Menu

Uploaded by

reny anil
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Python Questions Menu

Uploaded by

reny anil
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Name: Class: Date:

Python Questions Menu


1. Write a program that does the following:
a. Create an empty list of animals
b. Add an animal to the list
c. Remove an animal from the list
d. Display the list of animals
e. Close the program

Extension: Add options that will


f. Store the list of animals in a file
g. Open the file in read mode and output to a
display

# python questions menu

# animal menu
choice = "a"
animals = []
while choice != "e":
print("--------------- Menu -----------------")
print("| |")
print("| a) create an empty list of animals |")
print("| b) add an animal to the list |")
print("| c) remove an animal from the list |")
print("| d) display the list of animals |")
print("| e) close the program |")
Name: Class: Date:

print("------------------------------------------")

choice = input("What would you like to do: ")


choice = [Link]()

if choice == "a".lower():
print("You chose a")
animals = []
print(animals)

elif choice == "b".lower():


print("You chose b")
animal = input("Enter an animal: ")
[Link](animal)
print(animal + " has been added")
print(animals)

elif choice == "c".lower():


print("You chose c")
if len(animals) == 0:
print("The list is empty, no animals to remove.")
else:
print(animals)
remove_animal = input("Which animal would
you like to remove: ")
Name: Class: Date:

if remove_animal in animals:
[Link](remove_animal)
print(remove_animal + " has been removed
from the list.")
else:
print(remove_animal + "is not in the list.")
print(animals)

elif choice == "d".lower():


print("You chose d")
if animals:
print(animals)
else:
print("The list is empty.")

elif choice == "e".lower():


print("You chose e")
break

else:
print("Not an option")

You might also like