You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict n = int(input()) od = OrderedDict() for _ in range(n): *name_parts, item_price = input().split(' ') item_name = " ".join(name_parts) if item_name in od: od[item_name] += int(item_price) else: od[item_name] = int(item_price) for name, total in od.items(): print(f'{name} {total}')
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 →