Game Development Reference
In-Depth Information
D - Common Error Messages in Python
IndentationError: expected an indented block
def foo():
print('Hello world!')
This error happens if you fail to indent your code for a block. In the above example the
print() call is at the same level of indentation as the def statement, when it should have
a larger indentation.
IndentationError: unexpected indent
def foo():
print('Hello world!')
print('Goodbye')
An unexpected indent error happens when you add an indentation for no reason. You
should only add indentation after a def , if , else , elif , while , or for statment (or
any statement that ends with a colon.)
IndentationError: unindent does not match any outer indentation
level
def foo():
print('Hello world!')
print('Goodbye')
This indentation error appears when you are decreasing the indentation, but not
decreasing it to the same level as the previous indentation. The print('Goodbye') call
should either be at the same indentation as the other print() call (and be inside the if
block) or at the same indentation as the if statement (and be outside of the if block).
Search WWH ::




Custom Search