I want to import the random
module to use randint
and get a random number from 1 to 10. I have this so far:
import random
number = random.randint(1,10)
print number
I've also tried importing randint
specifically, but that doesn't work either. With the code above, I get object has no attribute 'randint.'
I've come across plenty of people getting this error. The solution has always been to find the file you've named random.py
and change its name because the script is loading that instead of the real module. I understand that, but I can't find that file; I've searched high and low, and the only file I can find named random.py
is the real module in the Python library list.
Aucun commentaire:
Enregistrer un commentaire