Who Called?

Python for AIMedium+10 XP+10

Who Called?

A phone book maps names to phone numbers. You see a number on your screen and want to know who it is.

Write reverse_book(phone_book) that returns a new dictionary that maps each number to its name.

  • No two people share a number.
  • An empty phone book gives an empty dictionary.

Examples

phone_book = {'ada': '555-01', 'bo': '555-02'}
returns {'555-01': 'ada', '555-02': 'bo'}
phone_book = {"grace": "900-11", "linus": "900-22", "ada": "900-33"}
returns {'900-11': 'grace', '900-22': 'linus', '900-33': 'ada'}
phone_book = {}
returns {}

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run