You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict purchases = OrderedDict() N = int(input()) for _ in range(N): inputs = input().split() item = ' '.join(inputs[:-1]) try: purchases[item] += int(inputs[-1]) except KeyError: purchases[item] = int(inputs[-1]) for item, price in purchases.items(): print(item, price)
Seems like cookies are disabled on this browser, please enable them to open this website
Collections.OrderedDict()
You are viewing a single comment's thread. Return to all comments →