Sal's shipping

I did the code exactly as the video instructed and my print result was 32.6 and not 53.60 like the programmers return value. My code is below:

def shipping_cost_ground(weight):

if weight >= 2:
price_per_pound = 1.50
elif weight >= 6:
price_per_pound = 3.00
elif weight >= 10:
price_per_pound = 4.00
else:
price_per_pound = 4.75

return 20 + (price_per_pound * weight)

print(shipping_cost_ground(8.4))

you could “walk” through your code and fill the comparisons:

if 8.4 > 2:

which is true. so price_per_pound is now 1.5 pound

however, that can’t be right, can it? Given the package is heavier then 6 pound so price_per_pound should be 3 pound.

5 Likes

Your using " >" when you should be using “<”
Make sense?
Shark’s mouth should be facing the price per pound.

1 Like

yes, makes perfect sense…user error. cant believe that I missed that.

1 Like