mardi 15 septembre 2015

How can I restrict the number of times a list item is selected with random.choice()

I have got a list like L= [ "bus", "bike"] and I want to print randomly the items from the list

for i in range(10):
print"Customer i uses the", random.choice(L)

If I want for instance to print bus 6times and bike 4 times is there a way to do it in python?




Aucun commentaire:

Enregistrer un commentaire