Question 373 of 498
PCEP Control Flow, Loops, Lists and Logic Practice Question
Which THREE of the following are valid ways to iterate over a list?
⚠ Common exam trap
Python Institute often tests the distinction between creating an iterator with `iter()` and actually iterating over it, leading candidates to mistakenly think `iter(mylist)` alone is a loop construct.
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
✓
for i in mylist:
Python's `for i in mylist:` syntax directly iterates over each element of the list `mylist`, assigning the element value to the loop variable `i` in each iteration. This is the standard and most Pythonic way to traverse a list.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
for i in mylist:
Why this is correct
Direct iteration over elements.
- ✓
i = 0 while i < len(mylist): print(mylist[i]) i += 1
Why this is correct
While loop with manual index increment.
- ✗
foreach i in mylist:
Why it's wrong here
Invalid syntax in Python.
- ✗
iter(mylist)
Why it's wrong here
Returns an iterator object but does not iterate automatically.
- ✓
for i in range(len(mylist)):
Why this is correct
Iteration over indices.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. Which TWO of the following list operations modify the list in place?
hard- ✓ A.mylist.sort()
- B.mylist + [5]
- C.mylist.copy()
- D.mylist = mylist + [5]
- ✓ E.mylist.append(5)
Why A: `mylist.sort()` sorts the list in place, meaning it modifies the original list object without creating a new one. Option E is correct because `mylist.append(5)` adds the element 5 to the end of the list, directly mutating the original list object.
Last reviewed: Jun 30, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.