You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict N = int(input()) lines = [input().rsplit(' ', 1) for L in range(N)] ordered_dictionary = OrderedDict() for L in lines: ordered_dictionary[str(L[0])] = int(L[1]) if L[0] not in ordered_dictionary else int(ordered_dictionary[str(L[0])]) + int(L[1]) [print(o.strip(), p) for o, p in ordered_dictionary.items()]
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 →