suppose we have a list of dictionaries like this:
l = [{'a': 1, 'b': 2}, {'a': 3, 'b': 4}, {'a': 5, 'b': 6}]
I want to increment the value of each a-key by one. This is easy to achieve with a loop like this:
for dictionary in l:
dictionary['a'] += 1
But is it possible to do that with a combination of map and lambda as well? It has to be something like this:
l = map(lambda x: x+1, l)
But I don't know how to specify the a-key in the lambda. lambda x['a']
didn't work. Any suggestions?
Thanks in advance!