python random select no replace 1

python random select no replace

import random

aList = [20, 40, 80, 100, 120]
print ("choosing 3 random items from a list using random.sample() function")
sampled_list = random.sample(aList, 3)
print(sampled_list)

Here is what the above code is Doing:
1. We have a list of 5 items.
2. We are choosing 3 random items from the list.
3. We are printing the list of 3 random items.

Similar Posts