IndentationError: expected an indented block

created at 06-25-2021 views: 3

Solution:

Python is a language that is very sensitive to indentation, which brings confusion to many beginners, even if it is very experienced Python programmer, it is also possible to fall into the trap. The most common situation is that tabs and spaces can cause errors, or indent, and this is unable to use the naked eye. 

This error in compile, this error, IndentationError: Expected An Indented Block, indicates that it needs to be indented here, and you only need to turn in the space or Tab (but not mix) to turn it.

People often have questions: I don't have indentation at all, it is wrong, wrong, the indent place will indent, it will be erroneous, such as:

if xxxxxx
[Space] xxxxx

# or

def xxxxxx
[Space] xxxxx

# and also

for xxxxxx
[Space] xxxxx

The next line of the colon often needs indentation.

Please log in to leave a comment.