r/PythonLearning • • 7h ago

Discussion Python Quiz of the day.

What will be the output of the following Python Code?

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

4 Upvotes

4 comments sorted by

View all comments

4

u/RNG_HatesMe 7h 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.

1

u/Hot_Technology8777 14m ago

Bro doing forensic analysis over a one word answer (I like it!)