Skip to content
Home » Select Random Element from List : Python

Select Random Element from List : Python

The random.choice() function selects an element at random from a specified list. In order to select Random element from list follow the below code.

# random.choice() method
import random

# prints the random element from the given list
sample_list = [6,1,7,9,2,0]
print(random.choice(sample_list))

Output:

7

Also Read:

random.choice() Python