+ 2
What does this error mean?
IndentationError: unindent does not match any outer indentation level
7 Respostas
+ 6
I have explained it in here (just read, don't run).
https://code.sololearn.com/cT5BRIbkia21/?ref=app
+ 5
python doesn't work with brackets but instead with indents. For example if you write an if you need to set everythin inside the if one tab to the right.
inteligence = 1
if inteligence==1:
print("I am smart!")
else:
print("I have small brian!")
you can see that the prints aren't all the way to the left but instead moved more to the right. That different position acts like a bracket. If you want an if inside an if you need more position.
if inteligence>1:
print("I am smart!")
if intelligence>2:
print("Very Smart!")
here the print inside the second if is even more to the right and therefore part of the second if but not directly part of the first if.
You generate the correct indents with tab. Remember that they act like brackets so everything that isnt in the right position isnt part of the if you maybe want the command to be. Hope that helped. Good luck!
+ 4
This is what I’m working on and where I experienced the error if it helps:
https://code.sololearn.com/csfZ1SB59dy9/#py
+ 4
Line 3 to 5 have to be indented 4 spaces.
+ 3
Aymane Boukrouh, thanks!
You're right, I should probably mention that issue.
It seems to depend a bit on which environment you write in.
I've copypasted code from Sololearn to Pydroid before; added a line, all looked fine - and suddenly indentation error.
+ 1
HonFu you code was very helpful, I didn't actually know about line 31. But I think you forgot to mention one other thing, which is that tabs and spaces cannot be used in the same file.