Sals Shippig Project

The code I wrote matches the tutorial video exactly.
I keep getting this error when i try to test it:

Traceback (most recent call last):
File “script.py”, line 13, in
print(shipping_cost_ground(8.4))
File “script.py”, line 6, in shipping_cost_ground
elif wieght <= 10:
NameError: name ‘wieght’ is not defined

def shipping_cost_ground(weight):
if weight <= 2:
price_per_pound = 1.50
elif weight <= 6:
price_per_pound = 3.00
elif wieght <= 10:
price_per_pound = 4.00
else:
price_per_pound = 4.75

return 20 + (price_per_pound * weight)

print(shipping_cost_ground(8.4))

2 Likes

not sure if you are still stuck , you have it named as “wieght” while the rest is “weight”

1 Like

Hi,
def ground_shipping_cost(weight):
if weight <= 2.0:
return weight1.50 + 20
elif weight > 2 <= 6:
return weight
3 + 20
elif weight > 6 <= 10:
return weight4 + 20
else:
return weight
4.75 + 20
print(ground_shipping_cost(8.4))

premium_shipping_cost = 125

def drone_shipping_cost(weight):
if weight <= 2:
return weight * 4.50
elif weight > 2 <= 6:
return weight * 9
elif weight > 6 <= 10:
return weight * 12
else:
return weight * 14.25
print(drone_shipping_cost(1.5))

def cheapest_shipping_cost(weight):
ground = ground_shipping_cost(weight)
premium = premium_shipping_cost
drone = drone_shipping_cost(weight)

if ground < premium and ground < drone:
method = “ground shipping”
cost = ground
elif premium < ground and premium < drone:
method = “premium shipping”
cost = premium
else:
method = “drone”
cost = drone
cheapest_shipping_cost(17)
print(
“The cheapest option available is $%.2f with %s shipping.”
% (cost, method)
)

I’ve done the same thing, and it isn’t working. I’ve got a couple of questions around this exercise aside from why it is not working. I have seen modulos, I understand the concept from previous exercises, but I cannot grasp the jump from getting remainders to using it as string extrapolation. This baffles me, I would not have thought to use $%.2f or %s.