PCEP Control Flow, Loops, Lists and Logic Practice Question
A ticket system stores seat rows in the list rows = [[1, 2], [3, 4], [5, 6]]. A developer needs to print every individual seat number on its own line, in order, from 1 through 6. Which code accomplishes this?
⚠ Common exam trap
The trap here is stopping at one level of iteration and printing whole inner lists instead of their individual elements.
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 row in rows: for seat in row: print(seat)
Traversing a list of lists requires nested loops: the outer loop yields each inner list, and the inner loop yields each element within it. Printing the inner element inside both loops emits every seat number in order, one per line, which matches the required output of 1 through 6.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
print(rows)
Why it's wrong here
Printing the list directly displays the entire nested structure on a single line, such as [[1, 2], [3, 4], [5, 6]]. No individual seat number appears on its own line, and no iteration occurs. This shows the data but does not meet the requirement of printing each seat separately.
- ✗
for row in rows: print(row)
Why it's wrong here
This loop iterates over the outer list and prints each inner list as a whole, producing lines like [1, 2] and [3, 4]. The individual seat numbers are never separated. To reach the numbers, a second level of iteration over each inner list is required, which this code omits entirely.
- ✗
for seat in rows: print(seat[0])
Why it's wrong here
This loop visits each inner list once and prints only its first element, yielding 1, 3, and 5. The even-numbered seats are never printed, and the output stops after three lines. It also indexes position 0 of each inner list rather than iterating over the elements themselves.
- ✓
for row in rows: for seat in row: print(seat)
Why this is correct
The outer loop selects each inner list, and the inner loop walks that list element by element, printing 1, 2, 3, 4, 5, and 6 each on its own line. Nested loops are the standard way to traverse a list of lists, and the order is preserved because both loops advance forward through their sequences.
Go deeper
Related to this question
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 →
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.