I have a python 2D function f(x,y)
that returns a number for every pair x
and y
. I need to calculate f(x,y)
having the elements in a list x=[x0,x1,x2,x3], y=[y0,y1,y2,y3]
to obtain [f(x0,y0),f(x1,y1),f(x2,y2),f(x3,y3)]
. I am doing this task with a for loop
result=[]
for k in range(len(k)):
result.append(f(x[i],y[i]))
Is there a more pythonic way to do this?if possible with numpy arrays. Many thanks