{'pppp''xxxx''mmmm''aaaa''ssss' {'mmmm''xxxx'{'mmmm'because the rest of the comprehensions story relies upon underlying concepts we're not yet prepared to addresswe'll postpone further details until later in this book in we'll meet first cousin in and the dictionary comprehensionand 'll have much more to say about all comprehensions--listsetdictionaryand generator--later onespecially in and as we'll learn thereall comprehensions support additional syntax not shown hereincluding nested loops and if testswhich can be challenging to understand until you've had chance to study larger statements why setsset operations have variety of common usessome more practical than mathematical for examplebecause items are stored only once in setsets can be used to filter duplicates out of other collectionsthough items may be reordered in the process because sets are unordered in general simply convert the collection to setand then convert it back again (sets work in the list call here because they are iterableanother technical artifact that we'll unearth later) [ set( { list(set( ) [ list(set(['yy''cc''aa''xx''dd''aa'])['cc''xx''yy''dd''aa'remove duplicates but order may change sets can be used to isolate differences in listsstringsand other iterable objects too-simply convert to sets and take the difference--though again the unordered nature of sets means that the results may not match that of the originals the last two of the following compare attribute lists of string object types in (results vary in )set([ ]set([ ]{ set('abcdefg'set('abdghij'{' '' '' 'set('spam'set([' '' '' ']{' '' 'find list differences find string differences find differencesmixed set(dir(bytes)set(dir(bytearray)in bytes but not bytearray {'__getnewargs__'set(dir(bytearray)set(dir(bytes){'append''copy''__alloc__''__imul__''remove''pop''insert'more you can also use sets to perform order-neutral equality tests by converting to set before the testbecause order doesn' matter in set more formallytwo sets are equal if and other numeric types