Python: Making A Set of Dictionary Values -
i want create set values within existing dictionary passing function set being created in.
as example:
def function(dictionary):
say dictionary looks this: {'1': 'monday', '2': 'tuesday', '3': 'monday'}
what want set contains unique value elements of dictionary, this:
{'monday', 'tuesday'}
thoughts?
that be:
set(my_dict.values())
this work on both python3 , python2. method below more efficient on python 2:
set(my_dict.itervalues())
Comments
Post a Comment