What is Indentation?
- Indentation is the spaces at the beginning of a code line.
- It makes code readable.
- It is very important because it indicates a block of code in Python.
- If you don’t follow indentation an error will appear.
- Indentation is of 4 spaces or 1 Tab.
Example:
Input:
num=5
for i in range(num):
print(i)
- The gap coming before the line 'print(i)' is called indentation.
- here, indentation is representing that the line 'print(i)' as part of 'for' block.
Output:
0
1
2
3
4
Previous (Python Syntax)
Comments
Post a Comment