Created
April 7, 2017 07:46
-
-
Save abhinavkorpal/c2d9a18d5c89d0ef8f3701a767b045cb to your computer and use it in GitHub Desktop.
Collections.OrderedDict
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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