lists and dictionaries

Ladislav Andel ladaan at iptel.org
Wed Jul 11 21:08:32 CEST 2007


Hi,
I have a list of dictionaries.
e.g.
[{'index': 0, 'transport': 'udp', 'service_domain': 'dp0.example.com'},
{'index': 1, 'transport': 'udp', 'service_domain': 'dp1.example.com'},
{'index': 0, 'transport': 'tcp', 'service_domain': 'dp0.example.com'},
{'index': 1, 'transport': 'tcp', 'service_domain': 'dp1.example.com'}]

how could I make a new list of dictionaries which would look like:
[{'transports': ['udp','tcp'], 'service_domain': 'dp0.example.com'},
{'transports': ['udp','tcp'], 'service_domain': 'dp1.example.com'}]

Could you help me, please?

Lada






More information about the Python-list mailing list