ProgrammingModerateProduct-company MCQ pattern

What is printed?

What is printed?
t = (1, [2, 3])
t[1].append(4)
print(t)
  1. A. TypeError
  2. B. (1, [2, 3])
  3. C. (1, [2, 3, 4])
  4. D. (1, [2, 3], 4)

Correct answer: C. (1, [2, 3, 4])

The tuple cannot be changed (you cannot rebind t[1]), but the list stored inside it is mutable. append changes that list in place, so no error is raised.

More Python Programming questions

Exams that ask this topic