0
I don't get the meaning of indentation
5 Answers
+ 1
Hey Jelvin,
This might help you:
âIndentation refers to the spaces at the beginning of a code line.
Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.
Python uses indentation to indicate a block of code.â
Source:
https://www.w3schools.com/python/gloss_python_indentation.asp#:~:text=Indentation%20refers%20to%20the%20spaces,indicate%20a%20block%20of%20code.
I suggest you read the article for a better understanding. =}
+ 1
Indentation is required in python because it indicates which lines of code are specifically inside a certain block of code which will be used by a certain function or class during runtime
0
Jelvin consider what happens without indentation. How would you indicate to the Python interpreter which statements belong inside a loop or an if statement?
for i in range(64):
p <<= 1
if (p-1)%3==0:
flag = true
print(p)
Without indentation you cannot be assured of the intent of the code. Here it is with indentation:
for i in range(64):
p <<= 1
if (p-1)%3==0:
flag = true
print(p)
Now it is easy to see that all the statements belong inside the loop, and which ones are executed conditionally.
0
Indentation means space that is used to certify code.