mardi 4 août 2020

How do I get the 'random' module to work? Did I forget to import something, or do I need to install anything?

My code looks like this:

import random
x = random()
print (x)

and I get following error:

Traceback (most recent call last):
  File "random.py", line 1, in <module>
    import random
  File "C:\Users\joshu\Desktop\random.py", line 2, in <module>
    x = random()
TypeError: 'module' object is not callable

What did I do wrong? From my understanding, random should be installed with python, shouldn't it?




Aucun commentaire:

Enregistrer un commentaire