+ 15

Is it necessary to indent code in if statement .Without indentation why the program does not run ???

23rd Mar 2019, 10:20 AM
Shruti Mishra
Shruti Mishra - avatar
10 Respuestas
+ 13
i know but i want to know that without indentation why programm doesn't run
24th Mar 2019, 1:37 AM
Shruti Mishra
Shruti Mishra - avatar
+ 11
Python code depends on indentation. Other languages like C don't so much. But indentation is advisable to increase code readability. I am guessing you are coding in python?
24th Mar 2019, 11:35 PM
Sonic
Sonic - avatar
+ 8
You have finished Python tutorial. Shouldn't you know this already?
23rd Mar 2019, 10:55 AM
HonFu
HonFu - avatar
+ 7
Indention in .py is mandatory when dealing with conditional operators. Without so your code will run but report fatal errors.!
2nd Apr 2019, 5:39 AM
OkomoJacob
OkomoJacob - avatar
+ 6
Please use the search function before posting on Q&A to avoid duplicate questions. Thank you. Maybe you talking about python.. Python has its unique features.. Review this posts.. https://www.sololearn.com/discuss/50912/?ref=app https://www.sololearn.com/discuss/394450/?ref=app https://www.sololearn.com/discuss/120135/?ref=app https://www.sololearn.com/discuss/1324379/?ref=app
23rd Mar 2019, 10:24 AM
Scooby
Scooby - avatar
+ 3
Yes, in Python it is necessary
23rd Mar 2019, 10:22 AM
Vlad Serbu
Vlad Serbu - avatar
+ 2
Python code treats indentation as braces. It is necessary to do so for the interpreter to understand that it is in a loop or a condition.
25th Mar 2019, 3:31 AM
Anshumaan Mishra
+ 2
In python indentation is as important as semi colon in Java or C++.
29th Mar 2019, 8:56 AM
Yugyn Dprodigy
Yugyn Dprodigy - avatar
+ 1
As one who has used a variety of languages, it appears (guessing here...) that one of the benefits of Python is the simplicity of the syntax. The authors seem to have stripped out/eliminated a character in every statement by eliminating the need for matching delimiters that enclose a block of code, which could contain multiple statements. This agile structure, along with loose typing probably makes Python more compact and results in faster interpretation at runtime? I'm still taking the course, but this looks like the reason for the indentation, since one tab replaces two curly braces.
3rd Apr 2019, 11:33 PM
Nick Merchant asecivilnet
Nick Merchant asecivilnet - avatar
0
Well you know that other languages uses the curly braces But in python braces turned to white spaces Well it makes the code "looks good" ,readable and clean And main thing if you cant do indentation then how python knows that which belongs to which statement. If you write all if and all other things which needs indentation then python got confused which statement has to be or which block has to be translated or interpreted. Thas why indentation matters
3rd Apr 2019, 9:16 AM
Tony Stark
Tony Stark - avatar