pythonset

Why is the number of elements reduced when converting a list to a set?


I have a list with 7,200,000 elements in it. When I try to convert it with set() it cuts out to 4,500,000 elements.

What can I do to bypass this problem?

I'm using Python 3.2.2 x86 on Windows.


Solution

  • I think your list has duplicate elements which are removed in set. Sets include unique elements only.