+ 15
Is it necessary to indent code in if statement .Without indentation why the program does not run ???
10 ответов
+ 13
i know but i want to know that without indentation why programm doesn't run
+ 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?
+ 8
You have finished Python tutorial.
Shouldn't you know this already?
+ 7
Indention in .py is mandatory when dealing with conditional operators.
Without so your code will run but report fatal errors.!
+ 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
+ 3
Yes, in Python it is necessary
+ 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.
+ 2
In python indentation is as important as semi colon in Java or C++.
+ 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.
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