Signed up recently but had issues with the confirmation email?

Click Forgot password and follow the reset steps. You can choose the same password you used when you signed up. This should then provide access.

Remember to check Spam and Junk. The email will be from auth@progressbytes.co.uk.

Revision notesQuestionsFor schools
Revise Computing
Log inStart revising free
Revision notesQuestionsFor schoolsLog in
GCSE Computer Science/Supplementary programming practice/Iteration

Loop bugs

301.10 Iteration

Practise exam questions

Iteration — Note 4 of 4

Fix infinite + off-by-one loops.

What you need to know

An infinite loop runs forever because the condition never becomes False. An off-by-one error means the loop runs one too many or one too few times. Both are common bugs.

What to know

  • Infinite loop: condition never becomes False
  • Fix: ensure the loop variable changes each iteration
  • Off-by-one: range(1, 5) gives 1-4, not 1-5
  • Use range(1, 6) to include 5
  • Test with small values to verify loop count

Code examples

Off-by-one fix
python
# Bug: prints 1 to 4 (misses 5)
for i in range(1, 5):
    print(i)

# Fix: prints 1 to 5
for i in range(1, 6):
    print(i)
← Previous noteLoop patterns301.10 IterationNext topic →String length301.11 String Manipulation

Back to Iteration

Specification notes for programming are in Paper 2.

Iteration

Note 4 of 4

  1. 1FOR loops
  2. 2WHILE loops
  3. 3Loop patterns
  4. 4Loop bugs
Topic overview

© 2026 Revise Computing · revisecomputing.co.uk

Worried about something?Question Bank UpdatesPrivacy noticeTermsContact

Revise Computing is an independent revision resource. It is not affiliated with, or endorsed by, OCR (Oxford Cambridge and RSA Examinations).