I need to make a two dimensional dictionary in python. e.g. new_dic[1][2] = 5
new_dic[1][2] = 5
When I make new_dic = {}, and try to insert values, I get a <
new_dic = {}
Simply, you can use defaultdict
defaultdict
from collections import defaultdict new_dic = defaultdict(dict) new_dic[1][2]=5 >>>new_dic defaultdict(, {1: {2: 5}})