Dictionaries · routine
Swap keys and values
Write invert(d) returning a new dictionary where each value of d is a key and each key its value. The values in d are all different. Do not change d.
- right answers
- arguments left as they should be
Run adds print(invert({"a": 1, "b": 2})) after your code, to try it.
Stuck on the idea rather than the code? The Dictionaries lesson walks through it.