In Python 2 this code is OK:
f = lambda (m, k): m + k m = [1,2,3,4] k = [5,6,7,8] print(map(f, zip(m, k)))
but in Python 3 the following
You can use the same syntax in both Python 2 and Python 3 if you use itertools.starmap instead of map which unpacks the tuple items for us:
map
>>> from itertools import starmap >>> f = lambda m, k: m + k >>> list(starmap(f, zip(m, k))) [6, 8, 10, 12]