def cost_ground_shipping(weight):
if weight <= 2:
cost = 1.50*weight + 20
elif weight <=6:
cost = 3*weight + 20
elif weight <= 10:
cost = 4*weight + 20
else:
cost = 4.75*weight + 20
return cost
#print (ground_shipping(8.4))
premium_ground_shipping = 125
def drone_shipping(weight):
if weight <= 2:
cost = 4.50*weight
elif weight <=6:
cost = 9*weight
elif weight <= 10:
cost = 12*weight
else:
cost = 14.25*weight
return cost
#print(drone_shipping(1.50))
def cheapest_delivery_method(weight):
drone = drone_shipping(weight)
premium = premium_ground_shipping
ground = cost_ground_shipping(weight)
In here,
why can’t I put -
" drone = drone_shipping(weight)
premium = premium_ground_shipping
ground = cost_ground_shipping(weight)"
outside of the function cheapest_delivery_method?
Isn’t it like that if I put it outside, it would be accessible by all but here only accessible by the above function?
It’s showing NameError when i do so but why?