Hi Everyone,
I have a list of dictionaries like
world =
[{'continent':'Asia','continent_code':1,'ocean':'Pacific','country':'India','country_code':1,'state':'Kerala',
'state_pin':500001},
{'continent':'Asia','continent_code':1,'ocean':'Pacific','country':'India','country_code':1,'state':'Karnataka',
'state_pin':500002},
{'continent':'Africa','continent_code':2,'ocean':'Atlantic','country':'Egypt','country_code':2,'state':'East
Egypt', 'state_pin':700001},
{'continent':'Africa','continent_code':2,'ocean':'Atlantic','country':'Egypt','country_code':2,'state':'West
Egypt', 'state_pin':700002},
{'continent':'Africa','continent_code':2,'ocean':'Atlantic','country':'Egypt','country_code':2,'state':'North
Egypt', 'state_pin':700003}]
i am trying to to make it in this format
world = [{'continent':'Asia', 'ocean':'Pacific',
'countries':[{'country':'India',
'states':[{'state':'Kerala', 'state_pin':500001},
{'state':'Karnataka', 'state_pin':500002}]
}]
},
{'continent':'Africa', 'ocean':'Atlantic',
'countries':[{'country':'Egypt',
'states':[{'state':'East Egypt', 'state_pin':700001},
{'state':'West Egypt', 'state_pin':700002},
{'state':'North Egypt', 'state_pin':700003}]
}]
}
]
Please help me in this regard.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor