Answers for "python get more than 1 random choice from list"

12

how to print a random part of a list in python

import random

foo = ['a', 'b', 'c', 'd', 'e']
print(random.choice(foo))
Posted by: Guest on April-08-2020
0

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)
Posted by: Guest on November-02-2020

Code answers related to "python get more than 1 random choice from list"

Python Answers by Framework

Browse Popular Code Answers by Language