0

I don't get the meaning of indentation

18th Jan 2023, 8:56 AM
Jelvin
Jelvin - avatar
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. =}
18th Jan 2023, 8:59 AM
Tim G
Tim G - avatar
+ 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
19th Jan 2023, 1:29 AM
Danielle Bagaforo Meer
Danielle Bagaforo Meer - avatar
+ 1
Jelvin Python is not like some programming , indentation most be use for( condition /for/while/with/class) almost every thing in python , you need to get used to that
20th Jan 2023, 6:00 AM
Abdul rahmon
Abdul rahmon - avatar
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.
19th Jan 2023, 12:26 AM
Brian
Brian - avatar
0
Indentation means space that is used to certify code.
19th Jan 2023, 8:18 AM
Monu Kumar
Monu Kumar - avatar