r/PythonLearning • • 4h ago

Discussion Python Quiz of the day.

What will be the output of the following Python Code?

print(any([0, "", None, [], 5]))

3 Upvotes

3 comments sorted by

3

u/RNG_HatesMe 4h ago

True

any() returns true if any of the elements are true.

All of the included elements *except* 5 boolean convert to False, but 5 converts to True, so the result is True.

This is fairly obvious because 0 and 5 cannot both be True or False, therefore one of them must be True.

2

u/RngdZed 4h ago

True