0

Why that exact indented in python..? If we properly not indented it shows error..why.?

27th Jan 2017, 4:23 AM
eddula naresh
eddula naresh - avatar
4 Respostas
+ 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.
27th Jan 2017, 6:28 AM
Hatsy Rei
Hatsy Rei - avatar
+ 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.
27th Jan 2017, 4:36 AM
Jesus Manuel Bustamante Sierra
Jesus Manuel Bustamante Sierra - avatar
+ 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.
27th Jan 2017, 8:41 AM
Petr Hatina
Petr Hatina - avatar
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.
13th Feb 2017, 5:54 AM
Caleb Horton
Caleb Horton - avatar