You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict ordinary_dictionary = OrderedDict() N = int(input()) for _ in range(N): shopping = list(map(str,input().strip().split())) item = " ".join(shopping[:-1]) if item not in ordinary_dictionary.keys(): ordinary_dictionary[item] = int(shopping[-1]) else: ordinary_dictionary[item] += int(shopping[-1]) for item, product in ordinary_dictionary.items(): print(str(item) + " " + str(product))
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 →