Bug hunt

Fix the Broken Spell

Every programmer (even experts) makes typos. When Python can't understand a line, it stops and shows a SyntaxError. Syntax just means "the grammar rules of the language".

Two slip-ups cause most SyntaxErrors:

  • A missing quote: print("Hello)
  • A missing bracket: print("Hello"
print("Hello")  # ✅ quotes and brackets in matching pairs

Other slips cause other errors. Python cares about capital letters, so Print("Hello") gives a NameError. That means "I don't know anything called Print." The grammar is fine, but the name is wrong.

The error message shows the line number where Python got stuck. Start looking there, or on the line just above.

Assignment

Pip wrote a three-line spell to light the harbour, but it crashes. Run it, read the error, and fix the mistakes (there are two) so it prints:

Harbour lantern: ready
Harbour lantern: lit
Ships can sail home!