0

While I am changing a list to set.I am getting this kind of behavior:

>>> set([1,"False",False,True])
{False, 1, 'False'}
>>> set([True,"orange",1])
{True, 'orange'}

In first case, True is missing and in second, 1 is missing. Is this because of some kind of data loss due to type conversion? Or am I missing something here? The IDLE I am using is 3.7.9 . I have attached a screenshot if that might be helpful.screenshot of python REPL

Suraj
  • 11
  • 3

1 Answers1

1

set only contains unique items, and 1 is coerced to True, this is why the second True item disappears

ivan866
  • 554
  • 4
  • 10