-1

this is my code:

import turtle 
e = turtle.Turtle
e.speed(10)
d = 100
angle = 140
for i in range (1, 1000):
    e.forward(d)
    e.left(angle)
    d = d - 1

when i run the code and this thing pop up.

Traceback (most recent call last):
  File "C:\Users\User\Desktop\Python\TUrtle graphic.py", line 2, in <module>
    e = turtle.Turtle
AttributeError: 'module' object has no attribute 'Turtle'
Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • Does this answer your question? [Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-with-the-same-name-raises-attributeerro) – Karl Knechtel Apr 25 '23 at 13:39

1 Answers1

0

Instead of:

e = turtle.Turtle

you need to do:

e = turtle.Turtle()

Full code:

import turtle

e = turtle.Turtle()
e.speed(10)
d = 100
angle = 140

for i in range(1, 1000):
    e.forward(d)
    e.left(angle)
    d = d - 1

turtle.mainloop()

Note that d will eventually become negative so your forward will effectively become a backward for the majority of the iterations.

cdlane
  • 40,441
  • 5
  • 32
  • 81