Revise Computingrevisecomputing.co.uk
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates
At a glanceFeaturesStudentsPricingHow it worksFree GCSE notesExam dates

Knowledge organisers / Maintainable Code

Indentation

All topicsPractise exam questions
Knowledge organiser

Maintainable Code

301.7b

Format to show structure.

What you need to know

Python uses indentation to define code blocks (inside if, for, while, def). Consistent indentation (usually 4 spaces) is required — incorrect indentation causes errors.

Key points

  • Python requires indentation — it is not optional
  • Use 4 spaces per level (standard convention)
  • Code inside if/for/while/def must be indented
  • Inconsistent indentation causes IndentationError

Code examples

Proper indentation
python
if score >= 50:
    print("Pass")    # indented = inside if
    grade = "C"
else:
    print("Fail")    # indented = inside else
    grade = "U"