#548 · Dictionaries and sets · Beginner · 30 XP · about 5 min
A phone book is a dictionary that maps names, written like 'Ana Lima', to phone numbers. People type names in a hurry, so write lookup(book, name) that finds the number for name while ignoring upper and lower case and any spaces at the start or the end of what was typed.
If nobody in the book matches, return 'Not found'.
book = {'Ana Lima': '555-0101', 'Ben Ito': '555-0199'} lookup(book, 'Ana Lima') # returns '555-0101' lookup(book, ' ben ito ') # returns '555-0199' lookup(book, 'Cy Moss') # returns 'Not found'
The whole name has to match: 'Ana' does not find 'Ana Lima'. No two names in a book differ only in upper and lower case.
First solves only, ranked by stars and then time.