This error message occurs when the Python interpreter encounters a code block that should be indented, but isn't. Python indentation is a common issue in Python because whitespace is used to define code blocks, so proper indentation is critical for code to run correctly. Some common causes of this error include:
Forgetting to indent the statements within a compound statement
Forgetting to indent the statements of a user-defined function.
To fix the error, make sure that all lines in the code block are properly indented by the same number of spaces or tabs. . It is recommended to use 4 spaces for indentation in Python, tabulation or a different number of spaces may work, but it is also known to cause trouble at times. Tabs are a bad idea because they may create different amount if spacing in different editors .