I'm trying to rewrite the following code
dct = {}
x = 'x'
y = 'y'
z = 'z'
if x not in dct:
dct[x] = defaultdict(dict)
if y not in dct[x]:
dct[x][y] = defaultdict(dict)
if z not in dct[x][y]:
dct[x][y][z] = defaultdict(list)
dct[x][y][z]['b'].append(defaultdict(int))
dct[x][y][z]['b'][0]['g']+=1
Without the following lines:
if x not in dct:
dct[x] = defaultdict(dict)
if y not in dct[x]:
dct[x][y] = defaultdict(dict)
if z not in dct[x][y]:
dct[x][y][z] = defaultdict(list)
dct[x][y][z]['b'].append(defaultdict(int))
Ideally I would like to have syntax such as
dct = 'state what it is'
dct[x][y][z]['b'][0]['g']+=1