Home > Blockchain >  Why can't I store True in a Set?
Why can't I store True in a Set?

Time:10-01

I have this code:

mySet = {1,"2",3.0,True}
print("Set: " , mySet)

The output is

Set:  {1, 3.0, '2'}

What happened to the 'True' ?

CodePudding user response:

Because set save unique value one time and 1 and True == 1 are same. For this reason, you see 1 one time.

>>> {1,True}
{1}

>>> {0,False}
{0}

>>> {'1',True}
{'1',True}
  • Related