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}))

5 Upvotes

11 comments sorted by

View all comments

1

u/Sea-Ad7805 Oct 31 '26 edited Oct 31 '26

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.

2

u/clcodingupdates Nov 01 '26

Better luck next time.

2

u/Sea-Ad7805 Nov 01 '26

Thanks, always good to learn, or be humbled by making a mistake that you probably should have avoided as Python educator. These tests still trick you sometimes, nice job.