What will be the output of the following Python program?

import copy

a = [[1, 2], [3, 4]]
b = copy.copy(a)
b[0][0] = 99
print(a[0][0])
                        

Options

  • A. 1
  • B. 99
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. 99

Detailed Explanation

Shallow copy creates a new outer object but retains references to nested objects. Modifying a nested list also affects the original.