what is indentation error in python3?how to fix it? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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

7th Dec 2018, 10:56 AM
Vijay(v-star🌟)
Vijay(v-star🌟) - avatar
4 Answers
+ 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.)
7th Dec 2018, 11:19 AM
blackcat1111
blackcat1111 - avatar
+ 15
Thank u ever1 😀
7th Dec 2018, 4:02 PM
Vijay(v-star🌟)
Vijay(v-star🌟) - avatar
7th Dec 2018, 11:11 AM
HonFu
HonFu - avatar
+ 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")
8th Dec 2018, 11:11 PM
Asif Shahriar
Asif Shahriar - avatar