![]() |
VOOZH | about |
Indentation is used to organise and group statements into blocks of code. Unlike many other programming languages, Python uses indentation instead of braces {} to define code structure.
Output
ERROR!
Traceback (most recent call last):
File "<main.py>", line 2
print("I have tab Indentation ")
IndentationError: unexpected indent
Explanation:
All statements in a conditional block should have same alignment.
The code below demonstrate how we use indentation to define seperate scopes of if-else statements:
GeeksforGeeks... All set !
Explanation:
Indentation defines the set of statements that are executed repeatedly inside a loop.
1 2 3 4 5
Explanation: Both print(j) and j = j + 1 are indented, so they are part of the loop block. These statements keep executing until the condition j <= 5 becomes False.