A seating editor has a list of rows, and each row is a list of seat labels. The editor must be able to change row membership without changing the original seating plan. Copying only the outer list leaves the rows shared, so this time copy one more level.
The input is a list of row lists. Build a fresh outer list, then build a fresh list for every row occurrence. Copy the references stored in each row, rather than recursively copying the cells. If a cell itself is mutable, it will still be shared. This is a chosen boundary, not a general deep-copy routine.
badge = {"name": "Robin"}
row = [badge]
row_copy = list(row)
row_copy.append({"name": "Ari"})
print(len(row)) # 1
print(row_copy[0] is badge) # True
The example copies one row. Your function must repeat that operation for every row, including empty ones. Accumulate the copies in order. Do not use [same_row] * count to construct independent rows: multiplication repeats references and would make several positions share one new row.
The lower panel copies the inner list too, so replacing a cell in the copied row leaves the original row unchanged.
If the same row object appears twice in the source, create two separate row copies. This policy lets an editor change one occurrence without affecting the other. Preserve the cell references inside both copies. A loop that appends the original row would only reproduce the shallow-copy behavior from the preceding lesson.
Let r be the number of rows and c the total number of cell positions across all rows. Creating r row lists and copying c references takes O(r + c) time and O(r + c) new storage. Including r matters: a hundred empty rows still require a hundred separate row containers. No shape is assumed; rows may have different lengths. The original list and every original row must remain unchanged after a caller edits the returned rows.
The starter supplies the fresh outer list, row loop, and return. Your change is the row-copy operation inside the loop. A comprehension is also valid.
Edit main.py, then press Run to inspect the supplied probe. Press Submit to check the operation on additional inputs. You do not need to copy code from another lesson.