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

Knowledge organisers / IDE Skills

Error messages

All topicsPractise exam questions
Knowledge organiser

IDE Skills

301.18b

Understand what went wrong.

What you need to know

Python error messages tell you the type of error (e.g. SyntaxError, NameError) and the line number. Reading them carefully is the fastest way to find and fix bugs.

Key points

  • SyntaxError: typo or missing character (colon, bracket)
  • NameError: variable not defined or misspelled
  • TypeError: wrong type used in operation
  • The line number in the error points to where it happened
  • Read from the bottom of the traceback up

Code examples

Reading error messages
python
# SyntaxError: Missing colon
# if x > 5
#          ^
# SyntaxError: expected ':'

# Fix:
if x > 5:
    print("big")