When I compile the Python code below, I get
IndentationError: unindent does not match any outer indentation level
for Atom Users, Packages ->whitspace -> remove trailing whitespaces
this worked for me
I got this error even though I didn't have any tabs in my code, and the reason was there was a superfluous closing parenthesis somewhere in my code. I should have figured this out earlier because it was messing up spaces before and after some equal signs... If you find anything off even after running Reformat code
in your IDE (or manually running autopep8), make sure all your parentheses match, starting backwards from the weird spaces before/after the first equals sign.
in my case, the problem was the configuration of pydev on Eclipse
If you use Komodo editor you can do as it suggests in one of similar error messages:
1) select all, e.g. Ctrl + A
2) Go to Code -> Untabify Region
3) Double check your indenting is still correct, save and rerun your program.
I'm using Python 3.4.2
For example:
1. def convert_distance(miles):
2. km = miles * 1.6
3. return km
In this code same situation occurred for me. Just delete the previous indent spaces of line 2 and 3, and then either use tab or space. Never use both. Give proper indentation while writing code in python. For Spyder goto Source > Fix Indentation. Same goes to VC Code and sublime text or any other editor. Fix the indentation.
The line: result = result * i
should be indented (it is the body of the for-loop).
Or - you have mixed space and tab characters