Advertisement
Sabev

Mixed Phones

Jan 16th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. dict_phonebook = {}
  2. entry_list = []
  3. while True:
  4.     string_input = input()
  5.  
  6.     entry_list = string_input.split()
  7.  
  8.     name = entry_list[0]
  9.     if name == "Over":
  10.         break
  11.     phone = entry_list[2]
  12.  
  13.     if ord(name[0]) >= 48 and ord(name[0]) <= 57:
  14.         name = entry_list[2]
  15.         phone = entry_list[0]
  16.  
  17.     dict_phonebook[name] = phone
  18.  
  19. for name, phone in sorted(dict_phonebook.items()):
  20.     print(f"{name} -> {phone}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement