Collections.OrderedDict()

  • + 0 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()