I have this code to create 2d array by loop
result = dict()
final = dict()
with open(self.json_file , 'w') as outfile:
for entry in sections_list:
path_items = raw_config.items(entry)
for key,path in path_items:
final[key]=path
result[entry] = final
json.dump(result, outfile)
but in result i got all key, path for each entry ! What to do ???
final[key]=pathand thenresult[entry] = finalwhat do you expect to happen? You are also creating two dicts not a 2d array.finaldict, and you use it for everything. Also, you probably ought to read up on Python's data structures, because dicts aren't arrays.