We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 8: Dictionaries and Maps
Day 8: Dictionaries and Maps
Sort by
recency
|
2708 Discussions
|
Please Login in order to post a comment
Be Aware: After the n lines of phone book entries, there are an unknown number of lines of queries.
One of solutions: while True: try: ... except EOFError: ...
This is my submission in JS
im failing in test case1 but passing all the other ones im about to loose it
Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(input()) phone_book = {} for _ in range(n): entry = input().split() name = entry[0] phone_number = entry[1] phone_book[name]=phone_number try: while True: query = input() if query in phone_book: print(f"{query}={phone_book[query]}") else: print("Not found") except EOFError: pass