1

I'm trying to increase a_s by 1 for every element of list a that is bigger than the corresponding element of list b using lambda.

>>> a = [4, 5, 8]
>>> b = [1, 3, 9]
>>> a_s = 0
>>> a_sum = map(lambda x,y: (a_s + 1) if x > y else (a_s + 0), a, b)
>>> print (a_sum)
<map object at 0x01230890>

The output I'm expecting is 2 since the 0th and 1st elements of list a are greater than that of list b

1 Answers1

1

Solution is:

print (sum(a_sum))

OR

res = list(a_sum)
print (sum(res))
Vaibhav Jadhav
  • 2,020
  • 1
  • 7
  • 20