Values shared by multiple keys
Input
invert_mapping({'a': 1, 'b': 1, 'c': 2})
Output
{1: ['a', 'b'], 2: ['c']}
'a' and 'b' both mapped to 1, so 1 maps to the list ['a', 'b'].
Full lesson preview
Create an inverted mapping where each original value maps to the list of keys that referenced it.
Problem statement
Task
Examples
Input
invert_mapping({'a': 1, 'b': 1, 'c': 2})
Output
{1: ['a', 'b'], 2: ['c']}
'a' and 'b' both mapped to 1, so 1 maps to the list ['a', 'b'].
Input format
Output format
Constraints
Samples
Input
invert_mapping({'a': 1, 'b': 2})
Output
{1: ['a'], 2: ['b']}
Simple inversion where each value is unique.