Python Break and Continue Quiz

This Python quiz tests break, continue and the often misunderstood else clause on loops. Predict the output of short programs and learn exactly when a loop's else block runs.

Medium 10 questions ~6 minutes Pass at 80% Python 3.12

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What does this print?

for i in range(10):
    if i == 4:
        break
print(i)
Show the answer

D. 4 break leaves the loop while i is 4, and the loop variable keeps that value afterwards. It does not go back to 3 or finish at 9.

What this quiz covers

  • How break stops a loop early
  • How continue skips to the next pass
  • When the else of a for or while loop runs
  • break inside nested loops
  • Where else must be indented

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Which Python version?

Python 3.12. Every question about output was checked by running the code.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.