ProgrammingHardTCS NQT · Accenture

What is printed?

What is printed?
print(any(x > 2 for x in [1, 2, 3]), next(x for x in [1, 2, 3] if x > 1))
  1. A. True 3
  2. B. True 2
  3. C. False 2
  4. D. True 1

Correct answer: B. True 2

any stops at the first item greater than 2, which is 3, so the result is True. next returns the first item greater than 1, which is 2.

More Python Programming questions

Exams that ask this topic