Advertisement
AlexG2230954

Untitled

May 28th, 2022
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. persons = dict()
  2.  
  3. while True:
  4. try:
  5. person, product, count = input().split(" ")
  6. count = int(count)
  7. except: break
  8.  
  9. if persons.get(person, None) is None:
  10. persons[person] = dict()
  11.  
  12. if persons[person].get(product, None) is None:
  13. persons[person][product] = 0
  14.  
  15. persons[person][product] += count
  16.  
  17. p = list(persons.keys())
  18. p.sort()
  19.  
  20. for a in p:
  21. print("{}:".format(a))
  22. l = list(persons[a].keys())
  23. l.sort()
  24. for d in l:
  25. print("{} {}".format(d, persons[a][d]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement