I have a list of dictionaries like so:
l = [{"integer":"1"},{"integer":"2"},{"integer":"3"},{"integer":"4"}]
I would like to do something similar to the following so that each of the numbers which are the value pair for the "integer" key are returned as integers:
l = [{"integer":"1"},{"integer":"2"},{"integer":"3"},{"integer":"4"}]
r = map(lambda x: x["integer"]=int(x["integer"]), l)
print r
#[{"integer":1},{"integer":2},{"integer":3},{"integer":4}]
But this causes an error:
SyntaxError: lambda cannot contain assignment
Does anyone know of a clean way to do this in python? Preferably a oneliner using map or something similar?