What causes an IndentationError or TabError?


I’m having some trouble with the indentation of my code and am getting errors such as IndentationError and TabError. What may be causing those and how can I fix it?


While there are no strict rules on the amount of space to use per indent, you do have to be consistent - otherwise you may encounter an IndentationError.

You are also not allowed to mix spaces and tabs for indentation in Python 3. You could use either all spaces or all tabs, and mixing them would cause a TabError. It is most common to use 2 spaces per indent (as you may have seen on the Codecademy platform) or 4 spaces per indent (as recommended by the PEP8 style guide).

1 Like