def cross(a, b, w):
f1 = b - w
f2 = a - w
if f1 < 0:
f1 = f1 * (-1)
elif f2 < 0:
f2 = f2 * (-1)
else:
pass
return f1, f2
x = cross(10, 7, 5)
print(x)
I tried to make this more pythonic, e.g. shorten it and combine it with shorted one line if-conditions, though I couldn't find any way.. Does anyone know how to shorten it?
I want to make "both" the f1 and f2 positive if any of them is negative.