0

Code:

import turtle
import random
turtle.penup()
for i in range(20):
    x=random.randint(-200,200)
    y=random.randint(-200,200)
    turtle.setposition(x,y)
    turtle.dot()
turtle.done()

Error:

F:\Python>random.py
Traceback (most recent call last):
  File "F:\Python\random.py", line 2, in <module>
    import random
  File "F:\Python\random.py", line 5, in <module>
    x=random.randint(-200,200)
AttributeError: module 'random' has no attribute 'randint'
jonrsharpe
  • 107,083
  • 22
  • 201
  • 376
user7391532
  • 11
  • 1
  • 1

1 Answers1

3

Rename your file.

Make sure that no files are named random.py.

Gino Mempin
  • 19,150
  • 23
  • 79
  • 104
Marouane B.
  • 121
  • 7