Python programming

Create a list with values from an other list

Assuming that i have the following list


and from this list I want to create a new list randomly selecting specific number of values

then this is how it is being done for two random values of the fruits list

import random
random_fruits = random.choices(fruits, k=2)

which results to


Leave a Reply