ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
try:
    print([1, 2] < (1, 2))
except TypeError as e:
    print(e)
  1. A. '<' not supported between instances of 'list' and 'tuple'
  2. B. False
  3. C. True
  4. D. TypeError

Correct answer: A. '<' not supported between instances of 'list' and 'tuple'

list and tuple do not compare with each other, so < raises TypeError. The message names both operand types in the order the operator was applied.

More Python Programming questions

Exams that ask this topic