animal quiz game in python 1

animal quiz game in python

animal_list = ['Fish' , 'Tarantula' , 'Snake' , 'an Octopus']
animal=random.choice(animal_list)
print("Choice an animal:Fish,Tarantula,Snake and Octopus")
if     

Here is what the above code is Doing:
1. We import the random module.
2. We create a list of animals.
3. We use the random.choice() function to randomly choose an animal from the list.
4. We print a message to the user asking them to choose an animal.
5. We use an if statement to check if the user’s choice is equal to the randomly chosen animal.
6. If the user’s choice is equal to the randomly chosen animal, we print a message saying they won.
7. If the user’s choice is not equal to the randomly chosen animal, we print a message saying they lost.

Similar Posts