I would like to have a nested dictionary with a list of values that are attached to the sub-key. Can't get the sub-key to recognise.
month = {}
for row in date:
month.setdefault(row[1],{row[0]: []})
month[row[0]].append(row[4])
print(month[main_key][sub_key])
I expect a list of values to be populated out through the appending method. However, I keep getting a keyError.
The desired output:
{'row[1]': {'row[0]' :[row[4], row[4], row[4]],
'row[0]' :[row[4], row[4], row[4]]}}