Skip to content
Advertisement

All pairwise means between elements of 2 lists

Is there a function to all pairwise means (or sums, etc) of 2 lists in python?

I can write a nested loop to do this:

JavaScript

result:

JavaScript

but it feels like this is a very roundabout way to do this. I guess there is an option for a nested list comprehension as well, but that also seems ugly.

Is there a more pythonic solution?

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement