I would like to write a program that randomly selects an element from a list for 1000 trials. Then I would like to have the number of times each element was selected as output. For instance, here's some code:
import random
foo = ['rock', 'paper', 'scissors', 'lizard', 'spock']
print(random.choice(foo))
will return a single element from 'foo' at random. I'd like to run the random selection over an iteration of, say, 1000 times, and then print out how many times each element was selected. Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire