Practice mode Python

Which exception does Python raise when the body of an if statement is not indented?

Correct answer D. IndentationError

Explanation

Python uses indentation to define blocks, so a missing indented block after if, for, def and similar headers is a syntax problem reported as IndentationError, a subclass of SyntaxError. TabError, a further subclass, is raised specifically for inconsistent mixing of tabs and spaces, not for missing indentation.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.