fork download
  1. n = int(input())
  2. i = 0
  3. book = dict() #Declare a dictionary
  4. while(i < n):
  5. name , number = input().split() #Split input for name,number
  6. book[name] = number #Append key,value pair in dictionary
  7. i+=1
  8. while True: #Run infinitely
  9. try:
  10. #Trick - If there is no more input stop the program
  11. query = input()
  12. except:
  13. break
  14. val = book.get(query, 0) #Returns 0 is name not in dictionary
  15. if val != 0:
  16. print(query + "=" + book[query])
  17. else:
  18. print("Not found")
Success #stdin #stdout 0.08s 14168KB
stdin
3
sam 99912222
tom 11122222
harry 12299933
sam
edward
harry
john
tom
steve
stdout
sam=99912222
Not found
harry=12299933
Not found
tom=11122222
Not found