Write a Python program to select an item randomly from a list Using random.choice()


This program imports the "random" module and uses the "choice" function to randomly select and print one element from the list "animal". The list "animal" contains a list of strings representing different animals. The "random.choice" function is used to randomly select one element from the list and print it. The output will be a random animal from the list each time the code is run.

Source Code

import random
animal = ["Cat", "Dog", "Elephant", "Fox", "Tiger", "Lion", "Ponda"]
print(random.choice(animal))
 

Output

Fox

Example Programs