In Python, Indentation is the whitespace at the beginning of a line. In a Python program, the leading whitespace, including spaces and tabs at the beginning of the logical line, determines the indentation level of that logical line.
Indentation is used to align statements to make the code readable. It is also used to associate and group statements.
The level of indentation groups’ statements to form a block of statements. The statements in a block must have the same indentation level.
Python checks the indentation level and gives an error if the indentation is not correct.
Python Indentation Examples
Now we are giving an example to exhibit indentation error:
age=18 print("You are eligible to take admission for B.Tech")
In this example, there is a tab at the beginning of the second line. So an indentation error is occurring here.
The following is a Python program with the correct indentation:
# Loop with counter count=0 while count<5: print('Inside loop') count=count+1 print('Outside loop')