+ 1
I'm having a problem using the random.choice() python command. What should I do?
When I try to use random.choice() in order to take a random element from a list, I get a name error , saying that "random" is not defined. I know that random.choice() generally works on other python platforms. Do you know why it doesn't work or have a solution to make it work? I f not , I'd appreciate if you had an alternative to recommend. https://code.sololearn.com/314/#py
5 Respuestas
+ 3
Put
import random
At the top
+ 3
Are you importing the “random” module?
For example (at the top of your code):
import random
I am unable to see the code you shared so I’m just guessing based on the description you gave.
+ 3
The code you shared is python code in a Swift emulator 🤔
+ 2
Thank you for your help! I'm new to python and sometimes I even forget to do basic things.
+ 1
If you want, check the fake ID Generator I made using random.choice!https://code.sololearn.com/chWRFUKJeVyu/#py