Practice mode Python

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.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.