Assume I have the following list:
foo = [\'a\', \'b\', \'c\', \'d\', \'e\']
What is the simplest way to retrieve an item at random from thi
import random
my_list = [1, 2, 3, 4, 5]
num_selections = 2
new_list = random.sample(my_list, num_selections)
randIndex = random.sample(range(len(my_list)), n_selections)
randIndex.sort()
new_list = [my_list[i] for i in randIndex]
Duplicate of https://stackoverflow.com/a/49682832/4383027