Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import Dict
- with open('input.txt') as input_file:
- customers = dict() # type: Dict[str, Dict[str, int]]
- for line in input_file:
- name, product, amount = line.split()
- if name in customers and product in customers[name]:
- customers[name][product] += int(amount)
- elif name in customers:
- customers[name][product] = int(amount)
- else:
- customers[name] = {product: int(amount)}
- for name in sorted(customers):
- print(name, ":", sep="")
- for product in sorted(customers[name]):
- print(product, customers[name][product])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement