You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict N = int(input()) items = OrderedDict() for _ in range(N): item_name, net_price = input().rsplit(maxsplit=1) items[item_name] = items.get(item_name, 0) + int(net_price) for item_name, net_price in items.items(): print(f"{item_name} {net_price}")
Collections.OrderedDict()
You are viewing a single comment's thread. Return to all comments →