You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict noOfItems = int(input()) ordered_products = OrderedDict() for _ in range(noOfItems): product, price = input().rsplit(maxsplit=1) if product in ordered_products: ordered_products[product] += int(price) else: ordered_products[product] = int(price) for key, value in ordered_products.items(): print(f"{key} {value}")
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 →