r/PythonLearning • • Oct 31 '26

Python Quiz of the Day!

What will be the output of the following Python Code?

print(len({True, 1, 1.0, False, 0}))

4 Upvotes

11 comments sorted by

View all comments

5

u/RNG_HatesMe Oct 31 '26

It's 2, because True, 1, and 1.0 all equivalent to True, and False is equivalent to 0. Sets remove duplicate items based on equivalence.

1

u/Responsible-Age9224 Nov 01 '26

Thanks for explaining