1. Home
  2. Data Science
  3. Python
  4. What is the output of the following Python code snippet?

Added 25 Nov 2026

What is the output of the following Python code snippet?

import copy
a = [1, [2, 3]]
b = copy.copy(a)
b[1][1] = 99
print(a, b)
  1. [1, [2, 3]] [1, [2, 99]]
  2. [1, [2, 99]] [1, [2, 3]]
  3. [1, [2, 99]] [1, [2, 99]] Correct answer
  4. Error

Correct answer

C. [1, [2, 99]] [1, [2, 99]]

6 views

MCQSEXAM

Explanation

A shallow copy shares the inner list, so changing it affects both copies.

Reference

Asked in: Python Interview Advanced Python

https://docs.python.org/3/library/index.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is C? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Python MCQs

Practise all Python MCQs

Similar MCQs