Practice · Python

Practice break & continue

Use break to exit early and continue to skip an iteration, without breaking loop correctness.

break & continuewarming python…

Find the first valid multiple‑of‑10 score

Write a function first_valid_score(inputs) that scans the integer list inputs from left to right.

  • Stop processing as soon as the sentinel value -1 is seen (do not consider it a score).
  • Any score that is < 0** or **> 100 is invalid – skip it and continue with the next item.
  • Return the first valid score that is a multiple of 10 (i.e. score % 10 == 0).
  • If no such score appears before the sentinel (or the list ends), return None.

Examples

first_valid_score([5, -3, 70, 85, -1, 90])  # → 70
first_valid_score([3, 7, 13, -1, 20])      # → None
Press Run to see output, or Check to grade against the tests.

Want a whole course built around break & continue?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.