swapdict#

swapdict(d)[source]#

Swap the keys and values of a dictionary. Equivalent to {v:k for k,v in d.items()}

Parameters:

d (dict) – dictionary

Example::

d1 = {‘a’:’foo’, ‘b’:’bar’} d2 = sc.swapdict(d1) # Returns {‘foo’:’a’, ‘bar’:’b’}

New in version 1.3.0.