You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict items= OrderedDict() n= int(input()) for _ in range(n): item,space, net_price= input().rpartition(' ') items[item]= items.get(item,0)+ int(net_price) print(*[f"{item} {price}" for item, price in items.items()], sep='\n')
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 →
from collections import OrderedDict items= OrderedDict() n= int(input()) for _ in range(n): item,space, net_price= input().rpartition(' ') items[item]= items.get(item,0)+ int(net_price) print(*[f"{item} {price}" for item, price in items.items()], sep='\n')