=====Function Descriptions=====
collections.OrderedDict

An OrderedDict is a dictionary that remembers the order of the keys that were inserted first. If a new entry overwrites an existing entry, the original insertion position is left unchanged.

Example
Code
>>> from collections import OrderedDict
>>> 
>>> ordinary_dictionary = {}
>>> ordinary_dictionary['a'] = 1
>>> ordinary_dictionary['b'] = 2
>>> ordinary_dictionary['c'] = 3
>>> ordinary_dictionary['d'] = 4
>>> ordinary_dictionary['e'] = 5
>>> 
>>> print ordinary_dictionary
{'a': 1, 'c': 3, 'b': 2, 'e': 5, 'd': 4}
>>> 
>>> ordered_dictionary = OrderedDict()
>>> ordered_dictionary['a'] = 1
>>> ordered_dictionary['b'] = 2
>>> ordered_dictionary['c'] = 3
>>> ordered_dictionary['d'] = 4
>>> ordered_dictionary['e'] = 5
>>> 
>>> print ordered_dictionary
OrderedDict([('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', 5)])

=====Problem Statement=====
You are the manager of a supermarket.
You have a list of N items together with their prices that consumers bought on a particular day.
Your task is to print each item_name and net_price in order of its first occurrence.

item_name = Name of the item.
net_price = Quantity of the item sold multiplied by the price of each item.

=====Input Format=====
The first line contains the number of items, N.
The next N lines contains the item's name and price, separated by a space.

=====Constraints=====
0<N≤100

=====Output Format=====
Print the item_name and net_price in order of its first occurrence.

Difficulty: introductory

Starter code:

# Enter your code here. Read input from STDIN. Print output to STDOUT

Solutions:
import collections, re
n = int(input())
item_od = collections.OrderedDict()
for i in range(n):
    record_list = re.split(r'(\d+)$',input().strip())
    item_name = record_list[0]
    item_price = int(record_list[1])
    if item_name not in item_od:
        item_od[item_name]=item_price
    else:
        item_od[item_name]=item_od[item_name]+item_price
            
for i in item_od:
    print((i+str(item_od[i])))


from collections import OrderedDict

def __starting_point():
    num = int(input().strip())
    history = OrderedDict()
    
    for _ in range(num):
        get_log = input().strip().split()
        good = " ".join(get_log[:-1])
        sold = int(get_log[-1])
        if good not in list(history.keys()):
            history[good] = sold
        else:
            history[good] += sold
            
        
    for key in list(history.keys()):
        print(("{} {}".format(key, history[key])))

__starting_point()