You are viewing a single comment's thread. Return to all comments →
def col_net(): n = int(input()) dic = {} lis = [] for _ in range(n): line = input().strip() item,price = line.rsplit(' ',1) price = int(price)
if item in dic: dic[item]['quantity'] += 1 else: dic[item] = {'quantity':1,'price':price} lis.append(item) for item in lis: net_price = dic[item]['quantity'] * dic[item]['price'] print(f"{item} {net_price}")
col_net()
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 →
def col_net(): n = int(input()) dic = {} lis = [] for _ in range(n): line = input().strip() item,price = line.rsplit(' ',1) price = int(price)
col_net()