Changes inside a copied two-dimensional list

A Python program represents two rows of sample counts using lists. It creates a copy and then makes the changes shown below. After every statement executes, find the total of all entries in grid and the total of all entries in snapshot. Count every row position, even when two positions contain the same list. Give both totals as exact whole-number counts, with no decimal places.


Python
row = [2, 4]
grid = [row, row]
snapshot = grid.copy()
snapshot[0].append(6)
snapshot[1] = [9]
grid[0][0] = 7
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Mutable vs Immutable Questions: