May-11-2017, 12:27 PM
I have a dictionary to people's names and codes,like this:
And I have a list of codes,like this :
The first number in list is the parents number and the second children's number...I need to find my parents and their kids,And put them in a new dictionary... like this:
1 2 3 4 5 6 7 8 9 |
Names_and_codes = { "Emily" : 30623 , 'Ethan' : 21298 , "Chloe" : 40145 , "Olivia" : 61834 , "Daniel" : 51398 , "William" : 82523 , "Emma" : 70623 } |
1 2 3 4 5 6 |
codes = [[ 30623 , 70623 ], [ 61834 , 40145 ], [ 51398 , 21298 ], [ 21298 , 40145 ], [ 61834 , 82523 ], [ 21298 , 82523 ]] |
1 2 3 4 5 6 |
new_dic = { 'Ethan' : { 'Chloe' , 'William' }, 'Olivia' : { 'Chloe' , '"William' }, 'Daniel' : { 'Ethan' }, 'Emily' : { 'Emma' }} |