Problem with Sal´s shipping project

Hi can you help me with my code? The last task is in the project to find the cheapest of the shipping methods. So all went well until i asked myself when drone-shipping comes to the cheapest. The problem is the code never recommend it as the cheapest, so there has to be a bug.

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

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


premium_shipping = 125.0

def cheap (weight):
  if drone_shipping(weight) < ground_shipping(weight) and  drone_shipping(weight) < premium_shipping:
  	return print (str(drone_shipping(weight)) + "Drone_shipping")
  elif ground_shipping(weight) < drone_shipping(weight) and  ground_shipping(weight) < premium_shipping:
  	return print (str(ground_shipping(weight)) + "ground-sh")
  else :
  	return print (str(premium_shipping) + "prem")

cheap(4.8)
cheap(20)


in my cheap function has to be the bug, please help me :slight_smile:

Your test cases return the correct values. Try adding: cheap(1.8)

1 Like

oh, it´s kind of embarrassing for me but I was so sure that there is a bug, so I didn´t consider that the code would actual be right

Thank you :smile:

1 Like