Python TabError: meaning and fix

TabError: Tabs and spaces are mixed in the indentation.

Code that causes it

if True:
        print("a")
	print("b")
Open in the runner

Code you copied from elsewhere holds tabs. Your editor mixed tabs and spaces.

Make every indent 4 spaces. Delete the start of the line and type it again.

How to fix it

if True:
    print("a")
    print("b")
Open in the runner

Why it happens

A tab and a space look alike but are different characters to Python. Mixed in one block, they cannot be counted.

The official docs are in English. See it in the official Python docs

Back to the runnerMore errors