sets lists are extremely versatile tools that suit most container object applications but they are not useful when we want to ensure objects in the list are unique for examplea song library may contain many songs by the same artist if we want to sort through the library and create list of all the artistswe would have to check the list to see if we've added the artist alreadybefore we add them again this is where sets come in sets come from mathematicswhere they represent an unordered group of (usuallyunique numbers we can add number to set five timesbut it will show up in the set only once in pythonsets can hold any hashable objectnot just numbers hashable objects are the same objects that can be used as keys in dictionariesso againlists and dictionaries are out like mathematical setsthey can store only one copy of each object so if we're trying to create list of song artistswe can create set of string names and simply add them to the set this example starts with list of (songartisttuples and creates set of the artistssong_library [("phantom of the opera""sarah brightman")("knocking on heaven' door""guns nroses")("captain nemo""sarah brightman")("patterns in the ivy""opeth")("november rain""guns nroses")("beautiful""sarah brightman")("mal' song""vixy and tony")artists set(for songartist in song_libraryartists add(artistprint(artiststhere is no built-in syntax for an empty set as there is for lists and dictionarieswe create set using the set(constructor howeverwe can use the curly braces (borrowed from dictionary syntaxto create setso long as the set contains values if we use colons to separate pairs of valuesit' dictionaryas in {'key''value''key ''value 'if we just separate values with commasit' setas in {'value''value 'items can be added individually to the set using its add method if we run this scriptwe see that the set works as advertised{'sarah brightman'"guns nroses"'vixy and tony''opeth'