Advertisement
Guest User

08. Company Users

a guest
Jul 15th, 2020
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. text = input()
  2. companies = {}
  3.  
  4. while text != 'End':
  5.     text_spl = text.split(' -> ')
  6.     company = text_spl[0]
  7.     employee = text_spl[1]
  8.     if company not in companies:
  9.         companies[company] = []
  10.     if employee not in companies[company]:
  11.         companies[company].append(employee)
  12.  
  13.     text = input()
  14.  
  15. companies = sorted(companies.items(), key=lambda x: (x[0], x[1]))
  16.  
  17. for key, employee in companies:
  18.     print(key)
  19.     for name in employee:
  20.         print(f'-- {name}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement