Skip to content

Instantly share code, notes, and snippets.

@abhinavkorpal
Created April 7, 2017 07:46
Show Gist options
  • Save abhinavkorpal/c2d9a18d5c89d0ef8f3701a767b045cb to your computer and use it in GitHub Desktop.
Save abhinavkorpal/c2d9a18d5c89d0ef8f3701a767b045cb to your computer and use it in GitHub Desktop.
Collections.OrderedDict
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment