Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

Exhibit

count = 0
while count < 5:
    count += 1
    if count == 3:
        continue
    print(count, end=' ')

What is the output of the following code?

for i in range(1, 6):
    if i == 3:

continue

print(i, end=' ')

⚠ Common exam trap

Python Institute often tests the `continue` statement by making candidates forget that it only skips the current iteration, not the entire loop, leading them to incorrectly omit subsequent values or include the skipped value.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

1 2 4 5

The code uses a for loop with range(1, 6) and a continue statement when i == 3. When i equals 3, the continue skips the print(i, end=' ') statement, so 3 is not printed. The loop iterates through 1, 2, 4, and 5, producing the output '1 2 4 5'.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    1 2 3 4 5

    Why it's wrong here

    Printing 1 2 3 4 5 ignores the `continue` statement, which skips the remainder of the current iteration when `i == 3`, so 3 is never printed. It is tempting because `continue` resembles a no-op, and without it the loop would indeed print every value. `continue` is used to skip specific values while iterating.

  • ✓

    1 2 4 5

    Why this is correct

    When i equals 3, continue skips the remaining loop body, so print never executes for that value. The loop still iterates through 1 to 5, printing 1, 2, 4 and 5, each separated by a space via end=' '. Hence the output is 1 2 4 5.

  • ✗

    1 2 4

    Why it's wrong here

    The `continue` statement skips only the current iteration, so 3 is omitted while 1, 2, 4 and 5 still print — the loop does not terminate. This option tempts because `break` at `i == 3` would indeed stop the loop and yield exactly 1 2, making it the right answer had `break` been written instead.

  • ✗

    1 2 3 4

    Why it's wrong here

    Including 3 contradicts the continue statement, which skips the print for i equal to 3, so 3 never appears in the output. It tempts candidates who overlook the conditional and assume every value in the range is printed in sequence.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.