You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict n = int(input()) ItemPriceDic = OrderedDict() for _ in range(n): Inp = input().split() item_name = ' '.join(Inp[:-1]) item_price = int(Inp[-1]) if item_name in ItemPriceDic.keys(): ItemPriceDic[item_name] += item_price else: ItemPriceDic[item_name] = item_price for i in ItemPriceDic: print(' '.join(map(str,(i,ItemPriceDic[i]))))
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 →