I need to iterate following dict:
{'Tom': {'reading': ['excellent'], 'writing': ['B1', 'B2']}, 'Ben': {'reading': ['excellent'], 'writing': ['B2']}}
and write it in JSON file as:
{
'name': 'Tom'{
'skills':'reading#excelent', 'writing#B1', 'writing#B2'
}
'name': 'Ben'{
'skills':'reading#excelent', 'writing#B1''
}
}
Thanks for any advice.
Tried:
dict = {'name': '', 'skills': []}
for name, skills in persons.items():
#print(name, skills)
dict['name'] = name
for skills, rate in skills.items():
for tag in tag:
rate = f'{skills}#{rate}'
dict['skills'].append(rate)
print(dict)
with open('vms1.json', 'w') as jfile:
json.dump(dict, jfile, indent=2)
But all skills are applied to Ben