Collections.OrderedDict()

Sort by

recency

|

700 Discussions

|

  • + 0 comments
    from collections import OrderedDict
    
    N = int(input())
    
    items_dict = OrderedDict()
    for i in range(N):
        item_list = list(input().split())
        price = int(item_list[-1])
        item_list.pop()
        item_name = " ".join(item_list[::])
        
        if item_name in items_dict.keys():
            old_price = int(items_dict[item_name])
            new_price = old_price + price
            items_dict[item_name] = new_price
        else:
            items_dict[item_name] = price
    
    
    for item in items_dict:
        print(item, items_dict[item])
    
  • + 0 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)
        
    
  • + 0 comments

    Welcome the most popular Roblox exploit for Windows that works completely free..This tool is capable of running multiple scripts in popular Roblox games i.e. Blox Fruits, Tower of Hell, Adopt me, Murder Mystery 2, etc Using the Trigon Evo Executor, you can enhance your overall gaming experience by unlocking the additional features not available in the original game.

  • + 0 comments

    Welcome the most popular Roblox exploit for Windows that works completely free..This tool is capable of running multiple scripts in popular Roblox games i.e. Blox Fruits, Tower of Hell, Adopt me, Murder Mystery 2, etc Using the Trigon Evo Executor, you can enhance your overall gaming experience by unlocking the additional features not available in the original game.

  • + 1 comment
    from collections import OrderedDict
    orders = OrderedDict()
    for i in range(int(input())):
        name, _, price = input().rpartition(' ')
        orders[name] = orders.get(name, 0) + int(price)
    [print(*item) for item in orders.items()]