Python IndentationError: meaning and fix
IndentationError: The indentation does not fit.
Code that causes it
for i in range(3):
print(i)
Open in the runnerThe line under for, if or def is not indented. Lines in one block use different widths.
Indent every line in a block by the same 4 spaces.
How to fix it
for i in range(3):
print(i)
Open in the runnerWhy it happens
Python marks blocks with indentation instead of braces. If the widths drift, it cannot tell where a block ends.
The official docs are in English. See it in the official Python docs