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 valid — 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…
- A.
Always valid
- B.
Always invalid
- C.
Valid only when list L and tuple T store similar data types
- 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.