We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
from collections import OrderedDict
d = OrderedDict()
for _ in range(int(input())):
item, space, quantity = input().rpartition(' ')
d[item] = d.get(item, 0) + int(quantity)
for item, quantity in d.items():
print(item, quantity)
Cookie support is required to access HackerRank
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 →
Just 7 lines: