Skip to content
← Back to Community
What is an "AttributeError"?
Profile icon
ggigabyte

https://repl.it/@ggigabyte/Turtle-drawer
Just run it and you'll see.

The program worked on the offline IDLE.

Voters
Profile icon
CailenPatel
Profile icon
mariam781
Profile icon
ggigabyte
Comments
hotnewtop
Profile icon
ChezCoder

An attribute error is when an attribute doesn't exist in an object.

Example:

class object: attrOne = "Hello " attrTwo = "World" print( object.attrOne + object.attrTwo + object.thisAttrDoesntExist)

Returns:

Traceback (most recent call last):
File "", line 5, in
AttributeError: type object 'object' has no attribute 'thisAttrDoesntExist'

Explanation:

This is because in the example, we never declared thisAttrDoesntExist. We only declared attrOne and attrTwo. Calling thisAttrDoesntExist from the class object would return an AttributeError as the attribute doesn't exist.

Solution:

To solve this problem, we need to change the example a bit:

class object: attrOne = "Hello " attrTwo = "World" thisAttrDoesntExist = " It exists!" print( object.attrOne + object.attrTwo + object.thisAttrDoesntExist)

Solved Result:

Hello World It exists!

Final Explanation:

It works because the class named object now has the attribute declared. It now exists. So now the name is a bit deceiving isn't it?

Profile icon
ChezCoder

@ggigabyte So basically what i mean is to change line 46 to:

t_program = input('Turtle ControlPanel\n' + istruzioni + '\n> ')

EDIT: "\n" means newline.

Profile icon
SixBeeps

screen.textinput() [does not work](https://cs20.ca/Python/Overview/FirstTurtleProgram.html