[Solved] Recodifying values by key of a list of dictionaries


If you already have the helper functions then you only need to loop once through each item of the list and modify all your key:value pairs:

for i in list:
    i['key'] = recode_key(i['key'])
    i['anotherkey'] = recode_anotherkey(i['key'])
    i['yetanotherkey'] = recode_yetanotherkey(i['key'])

You would need to loop through the list once, touch all the keys that you need, and your helper function makes sure that you don’t update the key twice or with another value.

solved Recodifying values by key of a list of dictionaries