Jul-19-2020, 06:03 PM
(This post was last modified: Jul-19-2020, 06:03 PM by IcodeUser8.)
Hey guys,
Im kinda new to python programming but know most of the basics. Currently im using a platform named trinket.io .
Im trying to make an animal guessing game. My program is supposed to ask the user for a certain category of animals. For instance, Savanna, Tundra, Desert, and Tropical. I've made 4 lists of 5 animals each for the user to choose from based on which biome they choose. Anyway, whenever I type in tundra, it always shows the savanna list. Please reply if you know what is wrong(sorry if im using this wrong, im new to this forum).
Here is my code(i have only done the conditions for tundra and savanna):
Im kinda new to python programming but know most of the basics. Currently im using a platform named trinket.io .
Im trying to make an animal guessing game. My program is supposed to ask the user for a certain category of animals. For instance, Savanna, Tundra, Desert, and Tropical. I've made 4 lists of 5 animals each for the user to choose from based on which biome they choose. Anyway, whenever I type in tundra, it always shows the savanna list. Please reply if you know what is wrong(sorry if im using this wrong, im new to this forum).
Here is my code(i have only done the conditions for tundra and savanna):
import random savanna=['cheetah','lion','gazelle','wildebeest','elephant'] tundra=['artic fox','artic hare','lemming','muskox','rock ptarmigan'] tropical=['jaguar','sloth','gorrila','poison dart frog','toucan'] desert=['cactus wren','black-tailed jackrabbit','kangaroo rat','xerocole','camel'] lives=3 while True: category=input("pick a category of animals. Savanna, Tundra, Tropical, or Desert:") if category=='Savanna' or 'savanna': savannaRandom=random.randint(0,4) chosenAnimal=savanna[savannaRandom] while (lives>0 and (category=='Savanna' or 'savanna')): print 'You have ',lives,' lives' guess=input("Guess the animal between cheetah, lion, gazelle, wildebeest, or elephant-") if guess==chosenAnimal: print "you win!" break else: print 'Try again' lives=lives-1 elif category=='Tundra' or 'tundra': tundraRandom=random.randint(0,4) chosenAnimal1=tundra[tundraRandom] lives=3 while lives>0: print 'You have ',lives,' lives' guess1=input("Guess the animal between artic fox, artic hare, lemming, muskox, or rock ptarmigan-") if guess1==chosenAnimal1: print "you win!" break else: print 'Try again' lives=lives-1