Problem:https://www.hackerrank.com/challenges/py-collections-ordereddict/problem

Sample Code:


od=dict()
for i in range(int(input())):
    k,v=input().rsplit(' ',1)
    if k in od:
        od[k]=int(od[k])+int(v)
    else:
        od[k]=v    
for k,v in od.items():
    print(k,v)

Explanation:

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top