Advertisement
pacho_the_python

PhoneBook

Mar 14th, 2022
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.60 KB | None | 0 0
  1. people = input()
  2.  
  3. phone_book = {}
  4. condition = False
  5.  
  6. while True:
  7.     people_data = people.split("-")
  8.  
  9.     if people_data[0].isdigit():
  10.         for person in range(1, int(people_data[0]) + 1):
  11.             name = input()
  12.  
  13.             if name not in phone_book:
  14.                 print(f"Contact {name} does not exist.")
  15.             else:
  16.  
  17.                 print(f"{name} -> {phone_book[name]}")
  18.         condition = True
  19.  
  20.     else:
  21.         if people_data[0] not in phone_book:
  22.             phone_book[people_data[0]] = people_data[1]
  23.  
  24.     if condition:
  25.         break
  26.  
  27.     people = input()
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement