samedi 1 avril 2017

Random.choice not working correctly python

I have the following code for example:

n = ['321','243','780']
code = 'n'
letter = random.choice(code)

the problem is that when I run this code, the random choice function handles 'code' as the actual list so it just takes 'n', I want it to take a random element from the 'n' list, how can I do this? and I want to keep 'code' as a variable.




Aucun commentaire:

Enregistrer un commentaire