IndentationError: unexpected indent in Python: 10 Causes and Fixes (Plus TabError and "expected an indented block", Tested Examples)
Python raises IndentationError: unexpected indent when a line starts further right than the block it belongs to. Here are 10 real causes, from stray spaces and pasted code to tabs, exec() strings and invisible characters, each reproduced with real output and the exact fix.