[Solved] Why it is the length of my list different than the length of the same list cast to a set? [closed]


So effectively the set() will parse (or convert if you will) your list (or tuple) into a new “set” which will contain only distinct iterable elements.

  • In your first list: the len = 4 as is, and is 4 with any duplicates
    removed (which there are not in your first list).
  • In your second list: the len = 6 as is, but len = 5 with the duplicate 5 removed (third and fourth items in your second list) .

4

solved Why it is the length of my list different than the length of the same list cast to a set? [closed]