Conditions & Loops · Question 9 · Medium

continue is used inside a loop over range(1, 8). Which numbers are printed?

for i in range(1, 8):
    if i % 3 == 0:
        continue
    print(i, end=" ")
  1. 1 2
  2. 1 2 4 5 7
  3. 3 6
  4. 1 2 4 5 7 8
Answer and explanation

Answer: B. 1 2 4 5 7

Explanation: continue skips the print for multiples of 3, which are 3 and 6, and the loop carries on. range(1, 8) stops at 7, so the output is 1 2 4 5 7.

Previous: A for loop that searches for an even number has an else clause. What does this… · Next: enumerate() numbers a list of names starting from 1. What line is printed?

Practise conditions & loops

Try a fresh set of conditions & loops questions with an explanation after every answer, free and without signing up: Conditions & Loops practice. Or sit a full placement mock test.

More conditions & loops questions

More python practice

Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators · Python Strings · Lists & Tuples

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge