Yandex Translator translates "TabError: inconsistent use of tabs and spaces in indentation" as:
TabError: inconsistent use of tabs and spaces in indents
Which indicates that your indents (space to the left of the code) use both spaces and TAB .
Do not mix spaces and tabs. A code that mixes spaces and tabs may look different in different editors (tabs may correspond to different numbers of spaces). Visually, the indents that you see may differ from the indents, as their original author of the code intended. In turn, this may differ from how the python interpreter sees these indents . Python 3 automatically TabError throws out. In Python 2, it was necessary to -tt command line option to enable checking.
Padding matters in Python . The PEP-8 Code Style Guide for Python recommends using 4 spaces for each indent:
Use 4 spaces per indentation level.
Set your IDE to use spaces for indents by pressing the Tab ↹ key. There are tools that automatically format your code (autopep8, yapf ). You can enable them in your IDE so that they are executed each time the code is saved.
In the new code, tabs for indents should not be used. Tabs can be used in old code that already uses tabs.
The syntactic significance of indents in Python ensures that what you see is what you get :
if some_condition: if another_condition: do_something(fancy) else: this_sucks(badluck)
Compare with C code, indentation in which is misleading:
/* Warning: XXX bogus C code! */ if (some condition) if (another condition) do_something(fancy); else this_sucks(badluck);
Here else belongs to the internal if , despite the formatting. Errors of this kind are also encountered in practice ( "goto fail" in iOS ). In gcc 6, a new warning has been added -Wmisleading-indentation . Unlike Python, in C it is more difficult for the compiler to determine if the indent is correct or not (heuristics must be used).