I am trying to copy a dictionary of dictionary (person_profile) into a new dictionary of dictionary (person_info) because I am trying to merge two different dictionaries (person_profile and person_attribute into person_info) with not necessarily same length and key value. Below are my code (I changed the variable just to make it sound more simple):
for person in person_profile:
person_info.update({
person.id :
{'name' : person.name, 'age' : person.age}
})
# And call person_attribute again
for person in person_attribute:
person_info.update({
person.id :
{'occupation' : person.occupation, 'gender' : person.gender}
})
However above method seems to create a set instead of dictionary. I couldn't find how to do so in other articles. What is a recommended approach to this problem?
== ANSWERED
for person in person_profile:
person_info[person.id] = {'name' : person.name, 'age' : person.age}
for person in person_attribute:
person_info[person.id].update({
'occupation' : person.occupation, 'gender' : person.gender
})