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.
"draw_white_space": "all"
After applying the settings you can easily see it as shown below.
![inconsistent use of tabs and spaces in indentation](https://neps.in/wp-content/uploads/2021/02/rsz_11spaces-and-tabs-inconsistently-used.png)
…… – > 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 none
, boundary
or all
. To view all whitespaces:
"editor.renderWhitespace": "all",
Before VS Code 1.6.0
Before 1.6.0, you had to set editor.renderWhitespace
to true
:
"editor.renderWhitespace": true
Vim editor
You can open the file and give ESC : set list
Except spaces, every other whitespace characters will be clearly visible as shown below.
![](https://neps.in/wp-content/uploads/2021/02/vim-inconsistent-tab-spaces-example.png)
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.