Mar-12-2020, 07:45 PM
In your code, the __init__() method creates the data dict:
def init(data): data['first'] = {} data['middle'] = {} data['last'] = {}So, the keys are already set. When adding names to the second level dicts, the interpreter retrieves the empty dicts from the first level. In the original code, the interpreter cannot find those empty dicts because they do not exist.