Challenge - #50 - Collections.OrderedDict()

from collections import OrderedDict
od = OrderedDict()
for i in range(int(input())):
    item_name, blank , price = input().rpartition(' ')
    if item_name not in od:
        od[item_name] = int(price)
    else :
        od[item_name] += int(price)

for i in od.items():
    print(*i)

Comments

Popular posts from this blog

Challenge - #48 - Incorrect Regex

Challenge - #43 - Time Delta

Challenge - #52 - Set .discard(), .remove(), & .pop()