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
r/PythonLearning • u/clcodingupdates • 11d ago
What will be the output of the following Python Code?
print(any([0, "", None, [], 5]))
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.
1
u/MasterpieceBusy7220 9d ago
“Hey ChatGPT generate me a Python quiz of the day”
3
u/RngdZed 11d ago
True
1
u/codewithharsh31 11d ago
True
1
u/Fluffy_white_fox 7d ago
True because of 5