What is the output of the following Python code? print(all(), any())
Correct answer B. True False
Explanation
all() returns True if no element is falsy, which is vacuously true for an empty iterable. any() returns True only if at least one element is truthy, and an empty iterable has none, so it returns False. Remembering the equivalent loops in the documentation makes these edge cases easy to reason about.
Answer checked How we write and check questions
Discussion