Here is my code:
i used set() and it return [3, 14, 6]
items = [3, 6, 3, 3, 14]
set(items)
>>> set([3,14,6])
My question is how is the set function organizes it values output. If we think about this, 3 is the first number and 6 is the second on the list, so should it output [3,6,14] instead?
Sets are unordered. From the documentation:
Like dictionaries, the ordering is based on the hashes of the stored keys. You cannot rely on this apparent ordering to remain stable.
If you are interested in the underlying data model, the underlying data structure is called a Hash Table, but in sets only keys are stored, values are left empty.