Loading...
Loading...
IndentationError: unexpected indentPython uses indentation to define code blocks. This error means Python found an unexpected level of indentation — either too much, too little, or a mix of tabs and spaces.
Python 3 does not allow mixing tabs and spaces. Use spaces consistently.
# In VS Code: View → Command Palette → "Convert Indentation to Spaces"
# Or use autopep8 to fix automatically:
pip install autopep8
autopep8-- in -place your_file.pyPEP 8 (Python style guide) recommends 4 spaces per level.
# ✅ Correct — 4 spaces
def greet(name):
if name:
print(f"Hello, {name}")
else:
print("Hello, stranger")
# ❌ Wrong — mixed indentation
def greet(name):
if name: # tab
print(name) # spaces