Knowingly or unknowingly you have used spaces instead of tabs, or the tabs are inconsistent in your python code. To solve this problem you should first make it apparent what is culprit and where is the culprit. I mean to display the spaces and Tabs. To see that you can follow the steps below in the editor that you are using.
Sublime Text 3
Make all whitespace characters visible, in Sublime text you should edit Preferences > Settings > User Settings
In your User Settings file add this config. Also if this is the last line in the config don’t end with a comma.
After applying the settings you can easily see it as shown below.
…… – > Denotes the spaces
——- -> Denote the tabs
Also, make sure in Sublimetext 3 menu: Views -> Indentation > Indent using Spaces ( is checked, has tick mark )
VS Code 1.6.0 and Greater
editor.renderWhitespace is now an enum taking either
all. To view all whitespaces:
Before VS Code 1.6.0
Before 1.6.0, you had to set
You can open the file and give ESC : set list
Except spaces, every other whitespace characters will be clearly visible as shown below.
Steps to Fix these kinds of errors
- Don’t use tabs and spaces mixed.
- Always use spaces as tabs. In sublime text 3 you can enable this by View > Indentation > Indent using Space.