0
What is identataion in python ?
4 Answers
+ 4
The identation in Python is analog to curly brackets in java.
0
thank u
0
Indentation (in Python or whatever), is spacing wich will shift the begining of a line toward the center...
This is a first line.
This second line is indented.
This third one too.
This fourth one is no more indented.
This last one is again indented.
By this way, you better visually see wich lines in sub-blocks are related to wich parent, and where start and end those sub-blocks... without indentation:
This is a first line.
A second line.
A third one.
A fourth one.
A last one.
In most of programming languages, identation is highly recommended for improve readability (and so maintenance: update, debug, and so on), but not mandatory, as such sub-block are expicitly defined by opening and closing brackets:
This is a first line.
{
A second line.
A third one.
}
A fourth one.
{
A last one.
}
With long years of old languages practice, lot of programmers feel brackets and others semi-colons annoying, as well as noticed that for human eyes, brackets were not really enough to well distinguish the sub-blocks, so newest languages such as Ruby and Python, choose to avoid/reduce use of brackets and semi-colon, and enforce coder to use indentation for their own goodness. So, in Python and Ruby, indentation is mandatory, because computer (interpreter) use it to know where start and end block instead of using brackets ^^
0
thanks bro