curious curious - 5 months ago 30
Python Question

How to call a function for every for iteration of a zip of two lists?

I have two lists:


I want for each
of those two to call a function, but not to do it in a trivial way inside a for loop. Is there a pythonic way? I tried with a

map(func(i,v) for i,v in zip(a,b))

but it does not work


If the function func doesn't return anything, you could use:

any(func(i, v) for i,v in zip(a, b))

Which will return False but not accumulate the results.

This would not be considered "Pythonic" by many since any() is being used for its side-effects, and therefore isn't very explicit.