LearnFrenzy
Sign in Take a free test

Lists · Lists MCQ · Question 8

Shallow copy of a nested list Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 8 Back to Exercise

b = a.copy() where a = [[1], [2]]. Which change to b also affects a?

  • A b[0].append(9) Correct
  • B b.append([3])
  • C b[0] = [7]
  • D b.clear()
Correct Answer: Option A

copy() makes a new outer list, but its items are the same inner lists, so mutating an inner list is visible in both.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links