I'm trying to make program which automatically determines the cheapest method of mailing a package based on its weight.
The code is refusing to run however as I keep getting the following TypeError: '<' not supported between instances of 'function' and 'function'.
I tried turning the functions into floats with:
if float(cost_ground) < float(cost_drone) and float(cost_ground) < float(cost_premium):
But this returns the following TypeError: float() argument must be a string or a number, not 'function'.
Any advice and/or explanation on how to solve this?
Here is the full code:
def cheapest(weight):
def cost_ground(weight):
if weight <= 2:
return float((weight * 1.50) + 20)
elif weight <= 6:
return float((weight * 3.00) + 20)
elif weight <= 10:
return float((weight * 4.00) + 20)
else:
return float((weight * 4.75) + 20)
def cost_drone(weight):
if weight <= 2:
return float((weight * 4.50))
elif weight <= 6:
return float((weight * 9.00))
elif weight <= 10:
return float((weight * 12.00))
else:
return float((weight * 14.25))
def cost_premium(weight):
return 125.00
if cost_ground < cost_drone and cost_ground < cost_premium:
return "Ground shipping is the cheapest at $" + cost_ground
if cost_drone < cost_ground and cost_drone < cost_premium:
return "Drone shipping is the cheapest at $" + cost_drone
if cost_premium < cost_ground and cost_premium < cost_drone:
return "Premium ground shipping is the cheapest at $" + cost_premium