You are viewing a single comment's thread. Return to all comments →
6 lines :-) The dictionaries in latest python are ordered. Check out this talk by Raymond Hettinger.
store_item = dict() for _ in range(int(input())): key,_,value = input().rpartition(" ") store_item[key] = store_item.get(key,0) + int(value) for k,v in store_item.items(): print(k,v)
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 →
6 lines :-) The dictionaries in latest python are ordered. Check out this talk by Raymond Hettinger.