Write a Python program to shuffle and print a specified list


This program is using the python built-in module random to shuffle a given list of animal names. The first line is importing the function shuffle from the random module. Then the list of animal names is defined and assigned to the variable animal. The shuffle function is then used on the animal list, which randomly rearranges the elements of the list. Finally, the shuffled list is printed using the print() function.

Source Code

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

Output

['Fox', 'Cat', 'Tiger', 'Lion', 'Dog', 'Ponda', 'Elephant']

Example Programs