user3382238 user3382238 - 5 months ago 53
Python Question

i keep getting an error when i try and import turtle

import turtle
window = turtle.screen()
myTurtle.forward(100)
myTurtle.left(90)
myTurtle.forward(100)

window.mainloop()


I get this error when I try and use the code above and not sure why, because its the same as my lecturers slide show, I just wanted to test it for myself.

Traceback (most recent call last):
File "/Users/ruairimangan-cliff/Desktop/Foundations of Computer Programming/week 4/Week 4 'Functions'.py", line 72, in <module>
window = turtle.screen()
AttributeError: 'module' object has no attribute 'screen'

Answer

Make sure you read your errors well! A single typo/ mistyped capital can cause errors like this!

Change :

window = turtle.screen()

to :

window = turtle.Screen()

http://openbookproject.net/thinkcs/python/english3e/hello_little_turtles.html