The following is a script attempting to draw a turtle graphic using the Python turtle
module.
import turtle
wn = turtle.screen()
alex = turtle.Turtle()
alex.forward(50)
alex.left(90)
alex.forward(30)
wn.mainloop()
At runtime, the script produces the following traceback (with generic path to script).
Traceback (most recent call last):
File "</path/to/script>.py", line <number>, in <module>
wn = turtle.screen()
AttributeError: module 'turtle' has no attribute 'screen'
It appears that the turtle
module has a screen
attribute in its documentation. That being the case, why does this AttributeError
occur?
You're getting the error
Traceback (most recent call last):
File "</path/to/script>.py", line <number>, in <module>
wn = turtle.screen()
AttributeError: module 'turtle' has no attribute 'screen'
because the turtle library doesn't have an attribute screen
, but this is just a minor typo as the turtle library does have a Screen
attribute. The Python programming language cares about the case of letters, which is often described as case-senstive syntax or case sensitivity.