Multi dimensional dictionary in python
Question: 
    #!/usr/bin/python
    
    import sys
    from collections import defaultdict
    from collections import Counter
    
    new_dic_defaultdict = defaultdict(dict)
    #new_dic_defaultdict = defaultdict(int)
    
    file="SMSCDR_POSTPAID_150901235000_10.84.0.29_AS.log"
    
    fp=open(file,"r")
    str = fp.readlines();
    
    for line in str:
            array = line.split('|')
            system_id = array[55]
            Origin = array[12]
            TIME = array[0]
            message_id = array[62]
            new_dic_defaultdict[Origin][system_id] = new_dic_defaultdict[Origin].setdefault(system_id, 0) + 1;
    
    print new_dic_defaultdict
    

Here I can write two dimensional directory. If I add third dimension its not
working.

    
    
    Ex: new_dic_defaultdict[Origin][system_id][message_id] = new_dic_defaultdict[Origin][system_id].setdefault(message_id, 0) + 1;
    

How to solve this


Answer: You can use defaultdict like that:

    
    
    new_dic_defaultdict = defaultdict(lambda: defaultdict(int))
    

