dict_name[a][b][c][d] = 0
This is essentially the same as the following
temp_a = dict_name[a]
temp_b = temp_a[b]
temp_c = temp_b[c]
temp_c[d] = 0
So you just have three lookups, in which you get an object from a dictionary which just happens to be another dictionary. And then, in the final step, you make one dictionary assignment.
As we know, dictionary lookups take all constant time on average, so all those four operations are O(1) themselves. Combined, you get 4 × O(1), which is still O(1) (because constant factors are not significant for big O).
If you now increase the depth of that nesting, all you get is more temp_y = temp_x[k]
lines, which again is constant time. So you only increase the factor k
in k × O(1). And as said before, as long as k
is constant, the factor is not significant for big O, so you stay at constant time, regardless of your nesting depth.