Search code examples
pythonindentationatom-editor

atom editor indentation error with Python


I am new to atom, so I opened my existing code using atom and modified few lines, then when I tried running the code with python, I get the following error:

IndentationError: unindent does not match any outer indentation level

I realized that Atom editor does indent my code differently to what I had. refer to the attached picture below showing the different indentation styles. line 1300 is the old indentation and 1301 is the one created by Atom

How can I fix this without modifying my 1000+ line code and so that atom uses the same style of indentation.

enter image description here


Solution

  • You have mixed tabs and spaces in your code. You should use spaces, always.

    You can use this plugin to quickly fix your code, and please, use only spaces and 4 spaces for each level of indentation.