Sets are unordered collections of unique elements.


In [1]:
myset = set()

In [2]:
myset


Out[2]:
set()

In [3]:
myset.add(1)

In [4]:
myset


Out[4]:
{1}

In [5]:
myset.add(1)

In [6]:
myset


Out[6]:
{1}

In [7]:
myset.add(0)

In [8]:
myset


Out[8]:
{0, 1}

In [9]:
myset.add('mississippi')

In [10]:
myset


Out[10]:
{0, 1, 'mississippi'}

In [12]:
myset.add(22222222)

In [13]:
myset


Out[13]:
{0, 1, 22222222, 'mississippi'}

In [15]:
set('mississippi').sort()


---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-79aa6e38ee24> in <module>()
----> 1 set('mississippi').sort()

AttributeError: 'set' object has no attribute 'sort'

In [ ]: