You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict items = OrderedDict()
number_of_items = int(input())
for _ in range(number_of_items): *item_name_parts , price = input().split() item_name = " ".join(item_name_parts) price = int(price)
if item_name in items: items[item_name] += price else: items[item_name] = price
for item , total in items.items(): print(f"{item} {total}")
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 →
from collections import OrderedDict items = OrderedDict()
number_of_items = int(input())
for _ in range(number_of_items): *item_name_parts , price = input().split() item_name = " ".join(item_name_parts) price = int(price)
for item , total in items.items(): print(f"{item} {total}")