I'd like to flip the keys and the values in a dictionary.

Say I have this dictionary:

positions = {'secretary' : 'Jessica', 'IT manager' : 'Matt', 'sales worker' : 'Linda', 'boss' : 'Chris'}

and I want this:

employees = {'Jessica' : 'secretary', 'Matt' : 'IT manager', 'Linda' : 'sales worker', 'Chris' : 'boss'}

Is there an easy way to create "employees" such as employees = positions.function() Thanks for the help.

Make sure your dictionary values are unique and immutable when you do this:

inverted_dict1 = dict([(v, k) for (k, v) in dict1.iteritems()])