PCEP Control Flow, Loops, Lists and Logic Practice Question
A company uses a for loop to iterate over a list of transaction amounts. They want to skip negative amounts. Which statement inside the loop correctly achieves this?
⚠ Common exam trap
Python Institute often tests the distinction between `break`, `continue`, and `pass`, and the trap here is that candidates confuse `break` (which exits the loop) with `continue` (which skips to the next iteration), or think `pass` is a valid way to skip code when it actually does nothing.
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
✓
if amount < 0: continue
The `continue` statement immediately jumps to the next iteration of the loop, skipping any remaining code in the current iteration. When `amount < 0`, the loop will not process that negative transaction and will move to the next element in the list, effectively skipping negative amounts.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
if amount < 0: amounts.remove(amount)
Why it's wrong here
Mutating the list during iteration shifts indices, so the for loop skips the element immediately after each removal and can miss negative amounts entirely. It is tempting because remove() genuinely deletes an item, which suits cleaning a list in a separate pass rather than filtering mid-iteration.
- ✗
if amount < 0: break
Why it's wrong here
break exits the entire loop at the first negative amount, discarding all later transactions instead of skipping that one. continue is the statement that skips the current iteration and proceeds. break is tempting as an early-exit tool, but it is correct only when no further items should be processed.
- ✗
if amount < 0: pass
Why it's wrong here
pass is a no-op, so the loop body simply continues to the next amount; nothing is skipped and negative values still flow through the calculation. It is tempting as a placeholder for code not yet written, which is its actual purpose, not conditional filtering.
- ✓
if amount < 0: continue
Why this is correct
The continue statement immediately ends the current iteration and returns control to the loop header, so the negative amount is never processed. Placing it under 'if amount < 0' skips only negative values while all non-negative amounts still execute.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
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.