I want to define a function to which the input parameters can be omitted or have a default value.
I have this function:
def nearxy(x,y,x0,y0,z):
distance=[]
for i in range(0,len(x)):
distance.append(abs(math.sqrt((x[i]-x0)**2+(y[i]-y0)**2)))
...
return min(distance)
I want make x0
and y0
have a default value, and make z
optional if I don't have a z
value.
How can I do that? Thank you.