ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
pairs = list(zip([1, 2, 3], 'ab', [True]))
print(pairs, len(list(zip())))
  1. A. [(1, 'a', True), (2, 'b', None)] 0
  2. B. [(1, 'a', True)] 0
  3. C. [(1, 'a', True)] 1
  4. D. [(1, 'a', True), (2, 'b', True)] 0

Correct answer: B. [(1, 'a', True)] 0

zip stops at the shortest iterable, here the one-element list, so only one tuple appears. zip with no arguments yields nothing, so its length is 0.

More Python Programming questions

Exams that ask this topic