Plz give me concepts about identation in 'if' statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Plz give me concepts about identation in 'if' statement

29th Jul 2016, 12:56 PM
Roshan Maharjan
Roshan Maharjan - avatar
4 Answers
+ 3
It's just a syntax for example In other programming languages the block of code would be enclosed with { } ex: if(condition){ IF BLOCK STATEMENTS } else{ ELSE BLOCK STATEMENTS } Instead of this block of code differentiation python uses, colon and intendation ex if(condition): IF BLOCK STATEMENTS else: ELSE BLOCK STATEMENTS as u see the curly braces replaced with colon and indentation (4 spaces by default) It would be convenient for developers to remember the exact block of code they are dealing just by looking rather than counting the { } Especially in complex nested if statements Hope u got my point.
29th Jul 2016, 1:49 PM
sundar
sundar - avatar
+ 1
Definition of Indentation in English is a space before beginning of line or a paragraph. In python 4 spaces are used for indentation in if function to differentiate from other line of codes.
9th Aug 2016, 11:06 AM
Aijaz Shaikh
0
4 spaces by default...thats the one i didnt understood.
31st Jul 2016, 3:15 AM
Roshan Maharjan
Roshan Maharjan - avatar
0
It's for the differentiating blocks of code
31st Jul 2016, 6:09 AM
sundar
sundar - avatar