CBSE Class 11 Informatics Practices Question 31 of 80

Lists in Python — Question 9

Back to all questions
9
Question

Question 9

Consider the following lists:

L1 = ["this", "is", "a", "list"]
L2 = ["this", "is", "another list"]

Which of the following statements will result in an error?

  1. L1 = L2
  2. L1.copy()
  3. L2.append(1, 2, 3)
  4. L2.pop()
Answer

L2.append(1,2,3)

Reason — The append() method in list takes one argument and adds it as a single element to the end of the list. Using L2.append(1, 2, 3) will result in an error because it provides multiple arguments. The correct statement would be L2.append([1, 2, 3]) to add the entire list [1, 2, 3] as a single element to L2.