Advertisement
horozov86

Company Users

Mar 20th, 2023
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. dictionary = {}
  2.  
  3. while True:
  4.     line = input()
  5.     if line == "End":
  6.         break
  7.  
  8.     line_split = line.split(" -> ")
  9.     company_name = line_split[0]
  10.     employee_id = line_split[1]
  11.  
  12.     if company_name not in dictionary:
  13.         dictionary[company_name] = [] # списък от id-тата на дадената компания
  14.  
  15.     if employee_id not in dictionary[company_name]: # само ако даденото id го няма от списъка го добавяме
  16.         dictionary[company_name].append(employee_id)
  17.  
  18.  
  19. for company, employee_id in dictionary.items():
  20.     print(company)
  21.     for employee in employee_id:
  22.         print(f"-- {employee}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement