Home / Python Programming / Programming Mistakes

Free GCSE Python resource

The Most Common Python Mistakes GCSE Students Make

Five frequent errors, why they happen and the debugging habits that help students correct them.

1. Using = Instead of ==

A single equals sign assigns a value. A double equals sign compares two values. In a condition, Python needs a comparison: if answer == 10:. Ask whether the line is storing information or checking it.

2. Forgetting That input() Returns Text

User input is a string unless it is converted. Adding one to age will fail if age still contains text. Convert at the point where a number is required: age = int(input("Age: ")).

3. Off-by-One Errors with range()

The stop value is excluded. range(1, 6) produces 1, 2, 3, 4 and 5. Before running a loop, write down its first and final values.

4. Incorrect Indentation

Indentation shows which statements belong to a selection or loop. Code that is visually misaligned may run at the wrong time or raise an error. Use one consistent indentation level and check the block after each colon.

5. Case-Sensitive Name Errors

totalScore and totalscore are different names. Choose clear variable names and reuse the exact spelling and capitalisation.

A Better Debugging Routine

  1. Read the error message and line number.
  2. State what the program should do.
  3. Trace the current values.
  4. Change one thing.
  5. Test normal, boundary and unexpected inputs where appropriate.

Syntax Errors and Logic Errors Are Different

A syntax error prevents Python from understanding the program. A missing colon or inconsistent indentation are typical causes. A logic error allows the program to run but produces the wrong result. For example, using > where >= is required may fail only at a boundary value.

Students should first ask whether the code runs. If it does not, inspect the reported line and the line immediately before it. If it runs incorrectly, choose a small test case whose expected answer can be calculated by hand.

Use Tests That Reveal Problems

Suppose a program accepts a mark from 0 to 100. Testing only 50 is not enough. Useful tests include 0 and 100, values just inside important boundaries, and invalid values such as -1 or 101 if validation is part of the task. Each test should have an expected result before the program is run.

A Short Student Practice Task

number = input("Enter a number: ")
if number % 2 = 0:
print("Even")

This code contains three separate issues: input has not been converted to an integer, the condition uses assignment rather than equality, and the output line is not indented. Correcting one problem at a time helps the student understand each cause.

How Parents Can Support Programming Practice

Ask your child to explain what the program should do before they change it. Encourage them to keep a brief debugging log: the symptom, the cause and the fix. This builds a reusable problem-solving habit instead of dependence on someone else finding every error.

The free booklet includes explanations, corrected examples, debugging tasks and answers.

Download Free

Need more support?

Explore Python programming tuition, wider GCSE Computer Science tuition, or the guide to computational thinking.