Reputation: 2997
I have the following collection (response from http request):
[{'ParameterKey': 'AdminCCIDRBlock', 'ParameterValue': '10.10.196.0/23'},
{'ParameterKey': 'MyParameter', 'ParameterValue': 'true'}]
I need to send the same collection in another request but I have to change the value of MyParameter
to false
. So the collection would become:
[{'ParameterKey': 'AdminCCIDRBlock', 'ParameterValue': '10.10.196.0/23'},
{'ParameterKey': 'MyParameter', 'ParameterValue': 'false'}]
How can I do that nicely in Python?
Upvotes: 0
Views: 72
Reputation: 12140
I think you would need to traverse the whole list anyway, so:
for d in collection:
if d['ParameterKey'] == 'MyParameter':
d['ParameterValue'] = 'false'
Upvotes: 2