Challenge: Phone Book
Completed
Build a phone book and answer one search.
Input
A number n, then n lines of name number, then one name to search for.
Output
The number for that name, or Not found.
Example
Input
3 asha 98765 ravi 91234 meena 99887 ravi
Output
91234
Editor
Python
Hints
Store each name as a key and the number as its value.
get(key, "Not found") avoids a KeyError.
Solution explanation
A dictionary is perfect for look-ups by name. get() with a default handles names that aren't saved.
Show solution
book = {}
for _ in range(int(input())):
name, number = input().split()
book[name] = number
print(book.get(input(), "Not found"))