Suppose L is a list and T is a tuple. Evaluate the following Python statement…

2026

Suppose L is a list and T is a tuple. Evaluate the following Python statement and choose the correct observation regarding its execution:
L.extend(T)

  1. A.

    Always valid

  2. B.

    Always invalid

  3. C.

    Always invalid

  4. D.

    Valid only if data types match in both (e.g., all integers or all strings)

Attempted by 526 students.

Show answer & explanation

Correct answer: A

The correct answer is Option A (Always valid).

In Python, the extend() method of a list takes any iterable as an argument. A tuple is an iterable, so L.extend(T) will work without any error. It simply adds each element of the tuple T to the list L.

Example:
L = [1, 2]
T = (3, 4)
After L.extend(T) → L becomes [1, 2, 3, 4]

Thus, the statement is always valid.

Explore the full course: Rssb Senior Computer Instructor