Reputation: 149
I wanted to create a nested dictionary, like {'match':{'sam':65}, 'match':{'john':55}}. When I run my code it generate the final dictionary as {'match':{'sam':55},{'john':65}}. How should I create a nested dictionary as discussed above?
following is my code:
attribute = ['sam','john']
value = [65,55]
dict = {}
main_dict = {}
for j in range(len(attribute)):
dict[attribute[j]] = value[j]
for key, value in dict.items():
main_dict['match'][key] = dict[key]
Upvotes: 0
Views: 51