+ 14
what is indentation error in python3?how to fix it?
i was not able to fix indentation error in the above programme https://code.sololearn.com/cnXqb2M6gkEi/?ref=app
4 ответов
+ 10
Since Python doesn't have curly braces like other languages, it relies on the indentation to separate blocks of code. If Python decides your indentation is not satisfactory, it will throw you an error, since it cannot tell where each block of code is. (I face this problem often.)
From what I can tell about your code, I have tried to fix it to the best of my ability:
https://code.sololearn.com/cuPX56Ny0Q6n/?ref=app
(Also, have to tried using elif statements? They make the code cleaner and this error will not be encountered as often.)
+ 15
Thank u ever1 😀
+ 7
Maybe you want to (re)read about it:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2277/
+ 2
We know python does not have braces like java or c. Then how the compiler knows the block of the codes. That is why we use indentation. It represents the block of the code. Such as:
If x<0:
print("x<0")
print("x>0")