I have a list of 2 tuples:
l = [('a', 1), ('b', 2)]
and I want to be able to map this to a dictionary object so that I can do something like
l.a
So, I tried this, but why doesn't it work?
d = reduce(lambda y,x : y.update({x[0]:x[1]}),l,{})
This gives an error:
AttributeError: object "NoneType" has no attribute 'update'
What am I doing wrong?
source
share