from itertools import starmap
from operator import sub
a = [8,9,4,7,5,6,1,4,8]
b = [6,4,7,1,5,8,3,6,4,4]
output = list(starmap(sub, zip(a, b)))
If you do not want to use list comprehension, this can be done with itertools.starmap.
You can also use a map, although I think starmap is the best option. Using a map, you can use nested zipto shorten a longer argument.
output = map(sub, *zip(*zip(a, b)))
print(list(output))
source
share