python indentation errors? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

python indentation errors?

24th Aug 2019, 8:51 PM
Musafir
Musafir - avatar
3 Answers
+ 4
what exactly is your question? what they are? because indentation errors is where you don’t use the correct indentation (how far the code is to the right) for example: if var == True: print(“yup”) the difference between where if is on the line (the start) and the print statement (one tab or four spaces) is what we call indentation (specifically the spaces) it shows us/it has us show the IDE where specific bits of code are. Code within an if statement needs to be “within” the if statement or indented as we say. other languages use {} to do this for example for(int i = 0; i < 5; i++) { some code written here } an indentation error in python would be for i in range(5): print(i) note the missing spaces before print, so print is not indented correctly
24th Aug 2019, 8:58 PM
Brave Tea
Brave Tea - avatar
+ 4
Brave Tea will Python accept two space indentation?
24th Aug 2019, 9:43 PM
Sonic
Sonic - avatar
+ 2
Sonic . Yep. Indentation size doesn't seem to matter. You don't even have to be consistent with the size.
24th Aug 2019, 9:54 PM
Rik Wittkopp
Rik Wittkopp - avatar