Sal's Shipping Unorderable Type

Getting the unorderable type error. Checked the two existing posts relating to this topic and couldnt solve mine. Only get this error for inputs 6 or less.

def cost_grnd_ship(weight):
if weight > 6 and weight <= 10:
return weight * 4.00 + 20.00
elif weight > 10:
return weight * 4.75 + 20.00

def cost_drone_ship(weight):
if weight <= 2:
return weight * 4.50
elif weight > 2 and weight <= 6:
return weight * 9.00
elif weight > 6 and weight <= 10:
return weight * 12.00
elif weight > 10:
return weight * 14.25

prem_grnd_ship = 125.00

def cost_to_ship(weight):
ground = cost_grnd_ship(weight)
drone = cost_drone_ship(weight)
premium = prem_grnd_ship

if ground < drone and ground < premium: #Line 24 Here
method = “Standard Ground”
cost = ground
elif drone < ground and drone < premium:
method = “Drone”
cost = drone
elif premium < drone and premium < ground:
method = “Premium”
cost = premium

print(“The cheapest method to ship is by %s shipping and the cost is $%.2f” % (method, cost))

cost_to_ship(4.8)

Traceback (most recent call last):
File “script.py”, line 37, in
cost_to_ship(4.8)
File “script.py”, line 24, in cost_to_ship
if ground < drone and ground < premium:
TypeError: unorderable types: NoneType() < float()

Perhaps this article will help with understanding the error message…

https://portingguide.readthedocs.io/en/latest/comparisons.html

Have you checked the value for ground. The error has to do with comparison of None to a float. Unmatched types will raise this exception when comparing.

1 Like