I am trying to read a list within a list and add keys and values to a dictionary within a dictionary. But I get the 'str' object doesn't support assignment error.
Code:
report_dict = dict()
axis_list = []
results = self.report_data(conn)
for row in results:
try:
report_dict[row[0]] = row[3]
report_dict[row[0]][row[3]] = row[1]
except IndexError:
None
print(report_dict)
Result:
report_dict = { abc: {qwe:asd}, …..}
resultslooks like?resultsvariable in your code, not the desired result of your code.rowis a list from which I am inputting abc, qwe,asd into the dictionary