The Python Set list type

Set’s are special in that they cannot contain a duplicate of the same value, each value must be unique:

mySet = ()

Sets do not have an order.

You can convert other types of list into sets using the set function, lets say that we have a tuple which contains 5 objects, 2 of which are identical:

myTuple = ('foo', 'foo', 'spam', 22, False, True)

And we convert it to a set:

print set(myTuple)
Output: set([False, True, 'foo', 22])

Notice that a ‘foo’ has been removed, and there is no particular order.