libb.invert

invert(dct)[source]

Invert a dictionary, swapping keys and values.

Parameters:

dct (dict) – Dictionary to invert.

Returns:

New dictionary with keys and values swapped.

Return type:

dict

Example:

>>> invert({'a': 1, 'b': 2})
{1: 'a', 2: 'b'}