You are viewing a single comment's thread. Return to all comments →
You can remove one more line by doing the print in 1 line:
from collections import OrderedDict D = OrderedDict() for _ in range(int(input())): item, space, price = input().rpartition(' ') D[item] = D.get(item, 0) + int(price) print(*[" ".join([item, str(price)]) for item, price in D.items()], sep="\n")
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 →
You can remove one more line by doing the print in 1 line: