Command Palette

Search for a command to run...

Hectal
Phase 2: Control Flow
Python · Exercise 4 of 6 PreviousNext
Beginner

Find the first multiple of 7 with break and else

A multiple of 7 is a number that 7 divides exactly, such as 14 or 49. The test n % 7 == 0 checks it.

Loop over numbers and store the first multiple of 7 in the variable first, then stop looping with break. If the list has no multiple of 7, first must be None.

Use the loop else for the "not found" case. Print First: followed by the value.

What Check tests

  1. [12, 25, 49, 50, 56] gives 49
  2. [14, 21] gives 14, not 21
  3. [1, 2, 3] gives None
  4. Your code uses break and a loop else
  5. The program prints First: 49

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

main.py
Sign in to run your code.

Output

Press Run to see what your program prints.