0
Why that exact indented in python..? If we properly not indented it shows error..why.?
4 odpowiedzi
+ 6
AFAIK, python enforces indentation instead of paranthesis to group lines of codes together into a block, e.g. :
if x > 1:
x += 1
x *= 2
and
if x > 1:
x += 1
x *= 2
is different in the sense that x *= 2 in the latter example is not within the if statement.
+ 1
Is a rule that was set to improve the code readability, I know that it is a hassle sometimes, but 9nce you get the flow to use four spaces or a tab (whatever you prefer) it will save you and whoever reads the code a lot of headaches.
+ 1
There is no exact indented in python. But - all lines in the block must be the same exact intented. This is the main reason of errors.
And - and this is an unfriendly problem, usually after copy code form another source, the intends get in mess, and must be recreated.
0
Some languages like JavaScript or C++ use curly brackets and other things when the computer processes the code. Thats just how the processing goes. Python is different and relies on tabs/spaces.