Bug Fix

The Shared Nested List

The Shared Nested List

Bug Report

A function duplicates a seating chart (a list of rows, each row a list of seats) so it can be modified independently. But editing the 'copy' also changes the original chart.

Shallow vs Deep CopyNested Listscopy module
Fix the Bug: The Shared Nested List

list.copy() (and slicing with [:]) only creates a SHALLOW copy — it duplicates the outer list, but the inner lists (or dicts/objects) inside are still shared references. Modifying a nested element affects both the original and the 'copy'. A true independent copy needs copy.deepcopy().

EditorPython · JSX
PreviewUpdates on Run Tests
Loading preview…
Tests
Should import the copy module
Should use copy.deepcopy() to duplicate the chart
Should NOT use the shallow .copy() method for this