# Sals shipping

Just looking for guidance on what I’ve done here I’m getting “NameError: name ‘weight’ is not defined” in the cheapest_shipping function.

``````premium_ground = 125

def ground_shipping(weight):
if weight <= 2:
cost = weight * 1.5 + 20
return cost
elif weight > 2 and weight <= 6:
cost = weight * 3 + 20
return cost
elif weight > 6 and weight <= 10:
cost = weight * 4 + 20
return cost
else:
cost = weight * 4.75 + 20
return cost

print(ground_shipping(8.4))

def drone_shipping(weight):
if weight <= 2:
cost = weight * 4.5
return cost
elif weight > 2 and weight <= 6:
cost = weight * 9
return cost
elif weight > 6 and weight <= 10:
cost = weight * 12
return cost
else:
cost = weight * 14.25
return cost

print(drone_shipping(1.5))

def cheapest_shipping(cheapest):
ground = ground_shipping(weight) #NameError: name 'weight' is not defined
drone = drone_shipping(weight)

if ground < premium and ground < drone:
cost = ground
delivery = "ground shipping"
elif drone < ground and drone < premium:
cost = drone
delivery = "drone shipping"

return ("The cheapest shipping is " + str(delivery) +", it will cost "+ str(cost))

package_1 = cheapest_shipping(4.8)
package_2 = cheapest_shipping(41.5)

print(package_1,package_2)
``````

you want to calculate the cheapest shipping based on the weight, so the parameter should `weight`. So you can pass different weights to calculate the cheapest shipping

why did you name your parameter `cheapest`? you could of course also change `weight` to `cheapest`, but weight seems like a more accurate description

1 Like

ahhhhh haha how did is miss that I was overthinking the problem. thank you