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