Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Names and codes
#1
I have a dictionary to people's names and codes,like this:
  Names_and_codes = {"Emily":30623,
                  'Ethan':21298,
                  "Chloe":40145,
                  "Olivia":61834,
                  "Daniel":51398,
                  "William":82523,
                  "Emma":70623}

 
And I have a list of codes,like this :
codes =[[30623 ,70623],
        [61834 ,40145],
        [51398, 21298],
        [21298 ,40145],
        [61834 ,82523],
        [21298, 82523]] 
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:
 new_dic = {'Ethan': {'Chloe', 'William'},
'Olivia': {'Chloe', '"William'}, 
'Daniel': {'Ethan'}, 
'Emily': {'Emma'}}

 
Reply


Messages In This Thread
Names and codes - by janek30 - May-11-2017, 12:27 PM
RE: Names and codes - by Larz60+ - May-11-2017, 12:36 PM
RE: Names and codes - by janek30 - May-11-2017, 02:40 PM
RE: Names and codes - by nilamo - May-11-2017, 03:59 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020