I am trying to make a function that randomly selects from two options nine times and returns the number of times each option was chosen. However, each time I try to run the code, the count function returns [None].
import random
topic=["Insomnia","REM Sleep Disorder"]
def func():
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
print(random.choice(topic))
x=[func()]
y=x.count("Insomnia")
print(x)
What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire