Sal's Shipping project dilemma

Hello everyone. This is my first post to the forums so please forgive me if I forgot something. I am currently working on Sal’s Shipping Project and everything was fine until running the final function. The problem I am having is that when I enter 4.5 as the argument I get “NONE”, but when I enter 41.5, the function works and says that Premium is the method and gives the cost. I’ve been working on this for the last 2 hours and just cannot seem to get this to work, even when trying the solution in the video provided. I’m hoping someone can take a look and tell me where I went wrong.

def ground_shipping_cost(weight):

  if weight <= 2.0:

    return weight * 1.50 + 20

  elif weight <= 6.0:

    return weight * 3.00 + 20

  elif weight <= 10.0:

    return weight * 4.00 + 20


    return weight * 4.75 + 20


premium_ground_shipping = 125

def drone_shipping_cost(weight):

  if weight <= 2.0:

    return weight * 4.50

  elif weight <= 6.0:

    return weight * 9.00 

  elif weight <= 10.0:

    return weight * 12.00


    return weight * 14.25 


def cheapest_shipping(weight):

  ground = ground_shipping_cost(weight)

  drone = drone_shipping_cost(weight)

  premium = premium_ground_shipping

  if ground < drone and ground < premium:

    method = "Ground shipping"

    cost = ground

  elif drone < ground and drone < premium:

    method = "Drone shipping"

    cost = drone


    method = "Premium shipping"

    cost = premium

    print("The cheapest method will be " + str(method) + " and it will cost $" + str(cost) + ".")

1 Like

Hello @donwick, welcome to the forums! Could you please format your code by pressing this button:

and inserting the code between the back ticks:Screen Shot 2020-05-02 at 14.06.13

1 Like

Well never mind everyone, I just figured out the problem :wink: I guess I just needed to take a step back and look again. I didn’t properly indent the print statement at the end of the last function. Once I did that everything worked. Well at least I got some experience using the forums.

Thanks anyway!


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.