Hi! I keep getting the same error in this exercise : https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-control-flow/projects/sals-shipping
My code looks like this :
def ground_shipping(weight): if weight <= 2.0: return weight * 1.5 + 20 elif weight <= 6.0: return weight * 3.0 + 20 elif weight <= 10: return weight * 4.0 + 20 else: return weight * 4.75 + 20 print(ground_shipping(8.4)) ground_premium_shipping = 125.0 def drone_shipping(weight): if weight <= 2.0: return weight * 4.5 elif weight <= 6.0: return weight * 9.0 elif weight <= 10.0: return weight * 12.0 else: return weight * 14.25 print(drone_shipping(1.5)) def cheapest_shipping(weight): ground = ground_shipping(weight) premium = ground_primium_shipping drone = drone_shipping(weight) if ground < premium and ground < drone: method = "ground_shipping" cost = ground elif premium < drone and premium < ground: method = "ground_premium_shipping" cost = premium else: method = "Drone_shipping" cost = drone print( "The cheapest shipping option is $%.2f with %s shipping." % (cost, method) <-- this is line 43 ) cheapest_shipping(4.8) cheapest_shipping(41.5)
I copied the last part from the video as I really got stuck there… But the interface doesn’t accept it and gives me this error message :
Traceback (most recent call last):
File “script.py”, line 43, in
% (cost, method)
NameError: name ‘cost’ is not defined
I really hope you guys can help me out because I don’t want to go further until this issue is resolved.
Thanks in advance!