0

Can anyone tell me why this code dosen't work?

import turtle
t = turtle.Pen
for x in range(100):
    t.forward(x)
    t.left(90)
turtle.done()
cdlane
  • 40,441
  • 5
  • 32
  • 81
  • 1
    Is this script itself named `turtle.py`? – John Gordon Jul 17 '22 at 17:27
  • Does this answer your question? [AttributeError: partially initialized module 'turtle' has no attribute 'Turtle' (most likely due to a circular import)](https://stackoverflow.com/questions/60480328/attributeerror-partially-initialized-module-turtle-has-no-attribute-turtle) – ggorlen Jul 17 '22 at 17:29
  • This is a classic turtle/Python gotcha. – ggorlen Jul 17 '22 at 17:29

1 Answers1

0

File name issues aside, this code won't run due to missing parentheses after Pen. Instead try:

import turtle

p = turtle.Pen()

for x in range(100):
    p.forward(x)
    p.left(90)

turtle.done()
cdlane
  • 40,441
  • 5
  • 32
  • 81