You are viewing a single comment's thread. Return to all comments →
`from collections import OrderedDict import re
groc = OrderedDict() for _ in range(int(input()): line = input() cost = re.findall(r'\d+', line)[0] new_line = line.replace(cost, "") groc[new_line] = groc.get(new_line, 0) + int(cost)
for key, val in groc.items(): print(key + str(val))
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 →
`from collections import OrderedDict import re
groc = OrderedDict() for _ in range(int(input()): line = input() cost = re.findall(r'\d+', line)[0] new_line = line.replace(cost, "") groc[new_line] = groc.get(new_line, 0) + int(cost)
for key, val in groc.items(): print(key + str(val))