Python Program to Randomly Select Elements From List Using choices()
# Randomly Select an more than Element From the List using choices() in python # importing random module import random # declaring list list = ['a', 'b', 'c', 'd', 'e', 'f'] # initializing the value of n n = 4 # printing n elements from list print(random.choices(list, k=n))
Output:
['b', 'a', 'c', 'c']