be generally compatible with both versions of python if you need to store the result of these methods as datamake copy by storing it in list for exampleitems list( items()if you simply want list of all keysuse keys list(mset types set is an unordered collection of unique items unlike sequencessets provide no indexing or slicing operations they are also unlike dictionaries in that there are no key values associated with the objects the items placed into set must be immutable two different set types are availableset is mutable setand frozenset is an immutable set both kinds of sets are created using pair of built-in functionss set([ , , , ] frozenset([' ', ,'hello']both set(and frozenset(populate the set by iterating over the supplied argument both kinds of sets provide the methods outlined in table table methods and operations for set types item description returns the number of items in makes copy of set difference returns all the items in sbut not in intersection returns all the items that are both in and in isdisjoint(treturns true if and have no items in common issubset(treturns true if is subset of issuperset(treturns true if is superset of symmetric_difference(tsymmetric difference returns all the items that are in or tbut not in both sets union(tunion returns all items in or len(ss copy( difference(ts intersection(tthe difference( ) intersection( ) symmetric_difference( )and union(tmethods provide the standard mathematical operations on sets the returned value has the same type as (set or frozensetthe parameter can be any python object that supports iteration this includes setsliststuplesand strings these set operations are also available as mathematical operatorsas described further in mutable sets (setadditionally provide the methods outlined in table table methods for mutable set types item description add(itemadds item to has no effect if item is already in removes all items from removes all the items from that are also in clear( difference_update(tf lib fl ff