X1263: Mirror Dictionary

You need some way to reverse the lookup process of some python dictionaries. While searching for a key in a dictionary is very fast, searching for a value in a dictionary is slow, since we would have to look through the entire dictionary. Instead of repeatedly doing this slow process, we'll instead create a reversed or mirrored dictionary: where the originial values and keys are reversed.

Complete the following function. Given aDict (which is a dictionary), return a separate dictionary where the keys and values are swapped.

Examples:

mirrorDict({3:1, 5:6, 7:"hi"}) -> {1:3, 6:5, "hi":7}

Your Answer:

Reset

Practice a different Python exercise

Feedback

Your feedback will appear here when you check your answer.