Lists & Tuples · Question 14 · Medium

Kavya has a list a and wants b to be a separate list with the same items, so that b.append(1) does not affect a. Which statement does this?

  1. b = a.copy()
  2. b = a
  3. b = (a)
  4. b = a.sort()
Answer and explanation

Answer: A. b = a.copy()

Explanation: a.copy() builds a new list holding the same items. b = a and b = (a) only make b another name for the same list, and a.sort() returns None.

Previous: A marks table is stored as a list of rows. What does this print? · Next: A two-element slice of a list is replaced by a one-element list. What is…

Practise lists & tuples

Try a fresh set of lists & tuples questions with an explanation after every answer, free and without signing up: Lists & Tuples practice. Or sit a full placement mock test.

More lists & tuples questions

More python practice

Dictionaries & Sets · Conditions & Loops · Functions & Scope · Comprehensions & Generators · Classes & Objects · Exceptions & Files · Built-ins & Standard Library · Variables, Types & Operators

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge