← SC in Schools Python

Syntax Errors and Debugging

An error that occurs when Python cannot understand your code due to a typo, missing quote, or wrong bracket; Python stops and shows a message with the line number

Understanding Syntax Errors and Debugging in SC in Schools Python

What it does: Debugging is a three-step process: locate the error, fix it, then re-run to confirm. Reading the line number in the error message tells you where to start looking for the bug. Python cannot run code it does not understand — it stops immediately and reports the error. Error messages appear in the console panel, just like program output. After fixing the bug, click Run again to check that the error is gone and the program works. Every programmer makes syntax errors — they are a normal and common part of writing code. Using the wrong type of bracket or forgetting to close one is a common syntax error.

Common mistakes: Python stops immediately when it finds a syntax error — it does not keep running. Line 0 is wrong. Python does not ignore syntax errors — it stops and shows an error message. Line 1 is wrong.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 64–73) and word search (Modules 64–73).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
What does Python do when it finds a syntax error?
Stops and shows an error messageSkips the line and continues
Matches
print(Hello, world!)
↓
Syntax error — string must be wrapped in quote marks
Applying
Meanings
Term
syntax error
Meaning
An error that occurs when Python cannot understand your code due to a typo, missing quote, or wrong bracket; Python stops and shows a message with the line number
Practice
print("Hello, world!)
Testing
Gaps
# A error means Python cannot run
Check Answer
Spots
1# Python keeps running after a syntax error
2# Syntax errors are caused by typos

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Nautilus' badge — Default Expert, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. What does Python do when it finds a syntax error?
A. Stops and shows an error message ✓
B. Skips the line and continues
Python cannot run code it does not understand — it stops immediately and reports the error.
2. Where does the error message appear in the editor?
A. The console panel ✓
B. The code area
Error messages appear in the console panel, just like program output.
3. What does the error message tell you that helps you debug?
A. The line number of the problem ✓
B. The fixed version of the code
The error message gives the line number so you know where to look, but you must fix it yourself.
4. A missing closing quote on a string causes a syntax error.
A. False
B. True ✓
A missing quote breaks the string literal and Python cannot parse the code — causing a syntax error.
5. What should you do after fixing a syntax error?
A. Click Reset to start over
B. Click Run to test the fix ✓
After fixing the bug, click Run again to check that the error is gone and the program works.

Match the Pairs

syntax error → An error caused by a typo, missing quote, or wrong bracket that stops Python running
print("Hello, world!) → Syntax error — the closing quote is missing from the string
Debugging means finding and fixing the error in your code → # Find the bug # Fix it # Click Run to test
The error message shows the line number where Python got confused → # SyntaxError on line 3 # Check line 3 for a typo
print(Hello, world!) → Syntax error — string must be wrapped in quote marks
# Python keeps running after a syntax error → Wrong — Python stops immediately and shows an error message

Key Term

syntax error
An error that occurs when Python cannot understand your code due to a typo, missing quote, or wrong bracket; Python stops and shows a message with the line number

Fill in the Blanks

1. # A syntax error means Python cannot run
Hint: Type the word for the type of error caused by a typo or missing quote
2. print("Hello, world") # no syntax error
Hint: Type the type of error this correct code avoids
3. # Fix the bug then click Run again
Hint: Type the name of the button you click to test your fix
4. # Read the error to find the line number
Hint: Type the word for what the error message tells you to locate the problem
5. print("Hello) # missing quote
Hint: Type the name of the missing character that causes this syntax error

Spot the Error

Question 1
A # Python keeps running after a syntax error
B # Syntax errors are caused by typos
C # Python shows an error message with a line number
Line A — Python stops immediately when it finds a syntax error — it does not keep running. Line 0 is wrong.
Question 2
A # A missing quote causes a syntax error
B # Python ignores syntax errors automatically
C # Fix the bug and click Run to test the fix
Line B — Python does not ignore syntax errors — it stops and shows an error message. Line 1 is wrong.
Question 3
A # The error message shows the line number
B # Read the error to find where the bug is
C # Syntax errors only happen on the last line
Line C — Syntax errors can happen on any line, not just the last one. Line 2 is wrong.
Question 4
A # Only beginners make syntax errors
B # Debugging means finding and fixing the error
C # A wrong bracket can cause a syntax error
Line A — Every programmer makes syntax errors — they are a normal part of coding at any skill level. Line 0 is wrong.
Question 5
A # Syntax errors are shown in the console
B # After fixing a bug click Reset to re-test
C # The error message includes a line number
Line B — After fixing a bug you should click Run to re-test, not Reset. Reset only restores starter code. Line 1 is wrong.

Student with a class code? Join your class →