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
  • 115,751
  • 26
  • 228
  • 437
user7391532
  • 11
  • 1
  • 1

1 Answers1

6

Rename your file.

Make sure that no files are named random.py.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
Marouane B.
  • 151
  • 7