ProgrammingHardTCS NQT · Wipro pattern

What is printed?

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

Correct answer: C. True True

Equality of lists compares their items, so a repeated list has the same contents as the explicit one. The inner empty lists are equal too.

More Python Programming questions

Exams that ask this topic