Loading...
Loading...
IndentationError: unexpected indentPython uses indentation (whitespace) to define code blocks, unlike languages that use curly braces {}. This error means you have an extra space or tab at the beginning of a line that doesn't match the surrounding block level.
In your editor (VS Code, PyCharm), run the 'Convert Indentation to Spaces' command.
# VS Code Palette (Ctrl+Shift+P) -> "Convert Indentation to Spaces"Ensure the line before the indented block ends with a colon :.
// ❌ SyntaxError (leads to confusion)
if x > 5
print(x)
// ✅ Correct
if x > 5:
print(x)Run 'black' or 'autopep8' to automatically fix all indentation issues.
pip install black
black my_script.pyFix this error faster with our free tool