Declaring a multi dimensional dictionary in python
A multi-dimensional dictionary is simply a dictionary where the values are themselves also dictionaries, creating a nested structure: You’d have to detect that you already created new_dic[1] each time, though, to not accidentally wipe that nested object for additional keys under new_dic[1]. You can simplify creating nested dictionaries using various techniques; using dict.setdefault() for example: dict.setdefault() will only set a key … Read more