Advertisement
horozov86

Phonebook

Mar 20th, 2023
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. phonebook = {}
  2.  
  3. number = 0
  4. while True:
  5.     input_line = input()
  6.     input_line_split = input_line.split("-")
  7.     if len(input_line) == 1:
  8.         number = int(input_line)
  9.         break
  10.  
  11.     name = input_line_split[0]
  12.     phone_number = input_line_split[1]
  13.  
  14.     phonebook[name] = phone_number
  15.  
  16. for _ in range(number):
  17.     name = input()
  18.     if name in phonebook:
  19.         print(f"{name} -> {phonebook[name]}")
  20.     else:
  21.         print(f"Contact {name} does not exist.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement