I'm mapping over an enumerated list and I'd like to access the index value when I'm not using a lambda function.
For example, I can access index values when using lambda like so:
arr = ['a', 'b', 'c', 'd']
map(lambda (i, v): { i: v }, enumerate(arr))
But I can't do the same when not using lambda:
map(parser, enumerate(arr))
def parser(i, v):
return { i : v }
The error I get is:
TypeError: parser() takes exactly 2 arguments (1 given)
Why is this the case??