Python Program to Randomly Select Element From List Using sample()
# Randomly Select an more than one Element From the List using sample() in python # importing random module import random # declaring list list = [2, 2, 4, 6, 6, 8] # initializing the value of n n = 6 # printing n elements from list print(random.sample(list, n))
Output:
[2, 2, 8, 6, 6, 4]