Kodewick
Start learning →
Basic←→0 / 100

Whose number is it

#064BasicDictsLoops4 min

Your phone is ringing, and the phone book is name to number. Write whose_number(book, number) to return who has that number, or "unknown" if no one in the book does.

Examples
whose_number({"Mom": "5551234", "Kai": "5559876"}, "5559876")→'Kai'
whose_number({"Mom": "5551234", "Kai": "5559876"}, "5550000")→'unknown'
main.py
def whose_number(book, number):
    for name, phone in book.items():
        # your code here: if the number matches, return the name
        pass
    return "unknown"
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.