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.
Answer checked How we write and check questions
Discussion