ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

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

Correct answer: A. ([1],) True

A tuple cannot change its own items, but the list inside it can be mutated. t[0] is the same list object each time.

More Python Programming questions

Exams that ask this topic