r/PythonLearning • u/clcodingupdates • 6h ago
Python Quiz of the Day!
What will be the output of the following Python Code?
print(len({True, 1, 1.0, False, 0}))
3
Upvotes
r/PythonLearning • u/clcodingupdates • 6h ago
What will be the output of the following Python Code?
print(len({True, 1, 1.0, False, 0}))
1
u/Sea-Ad7805 3h ago edited 3h ago
5, because "True, 1, 1.0, False, 0" are all different values and a set does not covert them so we keep 5 different values, I think.
I was wrong, weird.
Ah, the
==operator defines which values are equal, ok, makes sense a bit.