ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
list = [1]
try:
    print(list(range(2)))
except TypeError as e:
    print(e)
  1. A. TypeError
  2. B. 'list' object is not callable
  3. C. [0, 1]
  4. D. [1]

Correct answer: B. 'list' object is not callable

Assigning to the name list hides the built-in. list(range(2)) now calls the list object [1], which is not callable, so the error message names the object type.

More Python Programming questions

Exams that ask this topic