Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

A Python developer is writing a script to process a list of order IDs. The script must skip any order ID that is an empty string and continue processing the remaining IDs. Inside a `for` loop over the list, which statement should be used to skip the current iteration when an empty string is encountered and proceed with the next order ID?

⚠ Common exam trap

The trap here is choosing `break` when the intent is to skip only the current item; `break` ends the whole loop, while `continue` moves to the next iteration.

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

✓

continue

The `continue` statement abandons the current iteration and proceeds with the next element, which is the correct behavior for skipping empty order IDs while still processing the rest of the list. `break` would stop the loop entirely, `pass` does nothing, and `exit` would terminate the interpreter, so none of those match the filtering requirement.

Answer analysis

Option-by-option breakdown

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

  • ✗

    pass

    Why it's wrong here

    `pass` is a no-op placeholder that does nothing, so it would not skip processing; the remaining statements in the loop body would still run for the empty string. It is used when syntax requires a statement but no action is needed, not for altering loop flow to skip an iteration.

  • ✓

    continue

    Why this is correct

    `continue` skips the rest of the current iteration and jumps to the next item in the loop. When an empty string is detected, executing `continue` abandons processing for that order ID and moves directly to the next one, exactly matching the requirement to skip blanks while continuing through the list.

  • ✗

    exit

    Why it's wrong here

    `exit` is not a loop-control keyword; it is typically provided by the `site` module as a helper to terminate the interpreter. Using it inside a loop would end the whole program rather than skip one iteration. It also raises SystemExit, which is unsuitable for routine per-item filtering in a processing script.

  • ✗

    break

    Why it's wrong here

    `break` terminates the entire loop, so encountering the first empty order ID would stop processing all remaining IDs, not just skip that one. The requirement is to continue with the next order ID, which `break` prevents. It is appropriate only when the goal is to stop looping entirely.

About these practice questions

This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

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.