You are viewing a single comment's thread. Return to all comments →
You can use simple unpacking for the item name like this:
from collections import OrderedDict od = OrderedDict() for i in range(int(input())): *item, price = input().split() item = ' '.join(item) od.setdefault(item, 0) od[item] = od[item] + int(price) for k,v in od.items(): print(k + ' ' + str(v))
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 →
You can use simple unpacking for the item name like this: