from collections import defaultdict new_dic = defaultdict(dict) new_dic[1][2] = 5
new_dict = {'key':{'key':'answer'}}