-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkey-valuepair.py
More file actions
27 lines (26 loc) · 881 Bytes
/
key-valuepair.py
File metadata and controls
27 lines (26 loc) · 881 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
n = int(sys.stdin.readline().strip())
#reads 1 line -- the first line (3)
phone_book = dict()
#makes a dictionary
for i in range(n):
entry = sys.stdin.readline().strip().split(' ')
phone_book[entry[0]] = entry[1]
#goes through given inputs using the first line
#splits name and phone #
#enters them into the dictionary
query = sys.stdin.readline().strip()
#move on to second part
#read the queries (online the first line rn)
while query:
phone_number = phone_book.get(query)
#gets the # associated with the name
if phone_number:
#checks if its true (it exists)
print(query + '=' + phone_book.get(query))
else:
#phone # doesnt exist
print('Not found')
query = sys.stdin.readline().strip()
#continues on to the next one