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

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -