Reputation: 75
I am new to Python and I am learning about packages. I am trying to use the random module, but I get the TypeError: 'module' object is not callable
error. My code is:
import random
for i in range(3):
print(random.random())
Does anyone could tell me why this might be happening?
Regards
Upvotes: 0
Views: 985
Reputation: 35
What is the name of your file? If you named your file random.py, your script will not run.
Why do I get a TypeError: 'module' object is not callable when trying to import the random module?
I just tested your exact same code in a test.py file and it works no problem.
Upvotes: 1