I have read some other questions from stackoverflow, all they need to do it change file name to something else, but my file name is different already:
import random
x = random.random()
print(x)
and I got error like:
Traceback (most recent call last):
File "math.py", line 1, in <module>
import random
File "/anaconda3/lib/python3.6/random.py", line 42, in <module>
from math import log as _log, exp as _exp, pi as _pi, e as _e, ceil as _ceil
File "/Users/pgao/Documents/Python Project/math.py", line 3, in <module>
x = random.random()
AttributeError: module 'random' has no attribute 'random'
please help me with this simply question, i am selfstudy python language recently. thanks.
random.uniform(0,1)maybe. This will give a random float between 0 and 1. Orrandom.randint(lower, higher)where lower and higher are integers for a random integer.math.py, and it gets imported instead of the math module of the standard library. Rename it, and don't use names of standard modules for any of your files.