You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict N = int(input()) items_dict = OrderedDict() for i in range(N): item_list = list(input().split()) price = int(item_list[-1]) item_list.pop() item_name = " ".join(item_list[::]) if item_name in items_dict.keys(): old_price = int(items_dict[item_name]) new_price = old_price + price items_dict[item_name] = new_price else: items_dict[item_name] = price for item in items_dict: print(item, items_dict[item])
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 →