Let T be a tuple and L be a list. Evaluate the validity of the following…

2026

Let T be a tuple and L be a list. Evaluate the validity of the following Python statement:

L += T

and select the most appropriate option based on Python’s rules for sequence operations and data types.

Answer: A. Always validThe correct answer is Option A (Always valid). In Python, L += T for a list L and tuple T works because the += operator for lists behaves like extend(). It…

  1. A.

    Always valid

  2. B.

    Always invalid

  3. C.

    Valid only when list L and tuple T store similar data types

  4. D.

    Results in a Type Error

Attempted by 596 students.

Show answer & explanation

Correct answer: A

The correct answer is Option A (Always valid).

In Python, L += T for a list L and tuple T works because the += operator for lists behaves like extend(). It accepts any iterable, and a tuple is an iterable. So, elements of T are added to L.

Example:
L = [1, 2]
T = (3, 4)
L += T → [1, 2, 3, 4]

It does not require matching data types.

Thus, the statement is always valid.

Explore the full course: Rssb Senior Computer Instructor

Loading lesson…