When I compile the Python code below, I get
IndentationError: unindent does not match any outer indentation level
It could be because the function above it is not indented the same way. i.e.
class a:
def blah:
print("Hello world")
def blah1:
print("Hello world")
Just a addition. I had a similar problem with the both indentations in Notepad++.
Outer Indentation Level
Go to ----> Search tab ----> tap on replace ----> hit the radio button Extended below ---> Now replace \t with four spaces
Go to ----> Search tab ----> tap on replace ----> hit the radio button Extended below ---> Now replace \n with nothing
Whenever I've encountered this error, it's because I've somehow mixed up tabs and spaces in my editor.
On Atom
go to
Packages > Whitespace > Convert Spaces to Tabs
Then check again your file indentation:
python -m tabnanny yourFile.py
or
>python
>>> help("yourFile.py")
For SPYDER users: I'm using spyder 3.3.2 with python 3.7.1 and I solved this, setting indentation to use tabs, with the following steps, click on:
Then I reset the "unidented" line using tab key.
For some reason, without this setting, I got the ghost IndentationError sometimes.
If you are using Vim, hit escape and then type
gg=G
This auto indents everything and will clear up any spaces you have thrown in.