r/PythonLearning • u/clcodingupdates • 11d ago
Discussion Python Quiz of the day.
What will be the output of the following Python Code?
print(any([0, "", None, [], 5]))
5
Upvotes
1
1
1
r/PythonLearning • u/clcodingupdates • 11d ago
What will be the output of the following Python Code?
print(any([0, "", None, [], 5]))
1
1
1
8
u/RNG_HatesMe 11d 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.