Python lists – Select multiple random items from list

In this post we will be creating a script that will select multiple random items from a list, to do this we will be using the random module. The script will take input in the form of an integer which will define the number of random items to return.

See the snippet of code below where we have our list containing ten items.

import random


Number = int(input("Enter number of random items to select: "))

random_Choices = random.sample(List, Number)

When passing this script a value of ‘2’, the following is returned as output.

['Monica', 'Joe']

Leave a Reply