I am looking at the right way to smooth something like this
a = [{'name': 'Katie'}, {'name': 'Katie'}, {'name': 'jerry'}]
having
d = {}
Using a dual card:
map(lambda x: d.update({x:d[x]+1}) if x in d else d.update({x:1}),map(lambda x: x["name"] ,a))
I get the result I want:
>>> d
{'jerry': 1, 'Katie': 2}
But I feel that this can be done better .. not with a list of concepts tho, I feel that what we have is a map to reduce.
source
share