invert_dict#

invert_dict(d)#

Invert a dictionary with unique values.

Parameters:

d (dict[K, V]) – Input mapping with unique values.

Returns:

Inverse mapping from value to key.

Raises:

ValueError – If a duplicate value is encountered.

Return type:

dict[V, K]