Question 6
Back to Exercise
Booking seat (0, 1) should mark only one seat. Which statement correctly identifies the bug?
seats = [["-"] * 3] * 2
seats[0][1] = "X"
for row in seats:
print(" ".join(row))
- A join() copies the X
- B [row] * 2 repeats a reference to the same row list; build rows with [["-"] * 3 for _ in range(2)] Correct
- C Strings are shared between lists
- D The index should be seats[1][0]
Correct Answer: Option B
Both rows are one object. A comprehension creates a fresh row each time.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!