Question: CAN SOMEONE WRITE THIS CODE MORE EFFECTIVELY THEN I DID? I JUST WANT THE POSSIBILITIES OF SOLVING THE PROGRAM. THE CODE SHOULD BE IN PYTHON

CAN SOMEONE WRITE THIS CODE MORE EFFECTIVELY THEN I DID? I JUST WANT THE POSSIBILITIES OF SOLVING THE PROGRAM. THE CODE SHOULD BE IN PYTHON SINCE I ONLY KNOW THAT LANGUAGE CURRENTLY.

def main():

print("Welcome TO THE MOST EXTRAVAGANT ZOO IN THE WORLD!")

print("_______________________________________________________________________________________________________")

while True:

found = False

user_input = input('Query animal species[s], mass[m], litter[l], venom[v], wingspan[w], talk[t] or exit session[e]? ')

if user_input == "s" or user_input == "species" or user_input == "S" :

name = input("Enter The Name of the Animal:")

for i in animalsList :

if name == i.getName() and i.getType() == "Mammal" :

print(name , "species", i.getSpecies())

found = True

if not found:

print(name , "IS NOT A MEMBER OF THE ZOO")

elif user_input == "m" or user_input == "mass" or user_input == "M":

name = input("Enter the Name of the Animal:")

for j in animalsList :

if name == j.getName():

print(name, "Mass is:", j.getMass())

found = True

if not found:

print(name , "IS NOT A MEMBER OF THE ZOO")

elif user_input == "l" or user_input == "litter" or user_input == "L":

name = input("Enter the Name of the Animal:")

for k in animalsList :

if name == k.getName() and k.getType() == "Mammal":

print(name , "Litter Size is:", k.getLitterSize())

found = True

if not found:

print(name , "IS NOT A MEMBER OF THE ZOO")

elif user_input == "v" or user_input == "venom" or user_input == "V" :

name = input("Enter The Name of the Animal:")

for l in animalsList :

if name == l.getName() and l.getType() == "Reptile" :

print(name , "is:" , l.getVenomousOrNot())

found = True

if not found:

print(name , "IS NOT A MEMBER OF THE ZOO")

elif user_input == "W" or user_input == "wingspan" or user_input == "w" :

name = input("Enter The Name of the Animal:")

for m in animalsList:

if name == m.getName() and m.getType() == "Bird" :

print(name , "Wing Span is :" , m.getWingspan())

found = True

if not found:

print(name , "IS NOT A MEMBER OF THE ZOO")

elif user_input == "t" or user_input == "talk" or user_input == "T" :

name = input("Enter The Name of the Animal:")

for n in animalsList :

if name == n.getName() and n.getType() == "Bird" :

if n.getTalksOrMute() == "Mute" :

print(name, "Can't Speak")

else :

print(name, "Can Talk")

print(name , "Says" , n.getPhrase())

found = True

if not found:

print(name , "IS NOT A MEMBER OF THE ZOO")

elif user_input == "Quit" or user_input == "e" or user_input == "E" :

print("Thank You For Visiting Our Wonderful Zoo!")

break

else :

print("Please Take A Moment To Read The Menu Provided Carefully!")

txtToList()

main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!