ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
print(list(map(len, ['', 'ab', 'abc'])), sum(map(len, ['', 'ab', 'abc'])))
  1. A. [0, 2, 3] 3
  2. B. [0, 2, 3] 5
  3. C. [0, 2, 3] 6
  4. D. [1, 2, 3] 5

Correct answer: B. [0, 2, 3] 5

len of each string gives 0, 2 and 3. Their sum is 5, and the empty string contributes nothing.

More Python Programming questions

Exams that ask this topic