Question: a 9. Write a function swap(d, key1, key2) that takes a dictionary and two keys and swaps the values corresponding to both keys. If any

a 9. Write a function swap(d, key1, key2) that takes a dictionary and two keys and swaps the values corresponding to both keys. If any of the keys is not present in the dictionary, the function should print an error message. Sample Function Calls Sample Return values swap({1:'a', 2: 'b'], 1, 2) swap({1:'a', 2: 'b'}, 1, 3) {1:'b', 2: 'a'} "3 is not a key in the dictionary
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
