mardi 12 novembre 2019

random.choice does not work inside function in Python

Im trying to randomly print items from a list, and outside of a function it works perfectly.

import random

list = [1,2,3,4,5]

print(random.choice(list))

It prints randomly. However, when I put this inside a function, it always selects the same number (specifically 3). I don't understand why.




Aucun commentaire:

Enregistrer un commentaire