Consider the following Python declarations of two lists.

A = [1, 2, 3] 
B = [4, 5, 6]

Which one of the following statements results in A = [1, 2, 3, 4, 5, 6]?

A.
A.extend(B)
B.
A.append(B)
C.
A.update(B)
D.
A.insert(B)
Solution:

The question is asking which operation will result in:

A = [1, 2, 3]
B = [4, 5, 6]
# Desired result: A = [1, 2, 3, 4, 5, 6]

Explanation of options:

  • (A) A.extend(B)
    This adds each element of B to the end of A.
    → ✅ Correct. Result: [1, 2, 3, 4, 5, 6]

  • (B) A.append(B)
    This adds the entire list B as a single element to A.
    → Result: [1, 2, 3, [4, 5, 6]]

  • (C) A.update(B)
    list objects in Python do not have an update() method.
    → ❌ Invalid — causes an AttributeError

  • (D) A.insert(B)
    insert() requires two arguments: index and value.
    → ❌ Invalid — causes a TypeError

Correct Answer: (A) A.extend(B)