You are viewing a single comment's thread. Return to all comments →
from collections import OrderedDict menu = OrderedDict() n = int(input()) for _ in range(n): user_input = input() line = user_input.rsplit(" ", 1) item = line[0] price = int(line[1]) if item in menu: menu[item] += price else: menu[item] = price for thing, total_item in menu.items(): print(thing, total_item)
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 →