Sal's Shipping project issues

I created the following code, however it does not work. Why?

def better_method(weight):
if cost_drone_ship(weight) < cost_ground_ship(weight) and cost_drone_ship(weight) < premium_ground_ship:
return "Drone shipping is cheapest and costs " + str(cost_drone_ship(weight))
elif cost_ground_ship(weight) < cost_drone_ship(weight) and cost_ground_ship(weight) <premium_ground_ship:
return "Ground shipping is cheapest and costs "+ str(cost_ground_ship(weight))
else:
return "Premium shipping is cheapest and costs "+str(premium_ground_ship)

This block of code you specified couldn’t detect if some shipping cost is equal to each other, therefore in some case, for example when drone shipping cost is equal to ground shipping cost, it would return that premium shipping is cheapest method.

However this doesn’t make your code “does not work”, so I assume that former codes you written have an error. If you can send me your whole code I can have a boarder look at them

1 Like

Thank you very much for your help. I decided to just copy the solution from the video.

The video walkthroughs are there to help, of course, but I would encourage you - especially if your solution differed to the one in the video walkthrough - to spend some time looking at how the solution in the video works and examining how, if at all, your attempt failed to achieve the same outcome.

What I’m saying is that Codecademy is a learning environment, and so we’re geared up to help you if you get stuck - whether that’s by pointing you in the right direction, or giving you a working solution.

In the real world, there will most likely not be someone who can conveniently give you a working solution when you get stuck. Those will be the times where the difference between someone who just takes the answers and carries on, and someone who makes the effort to understand their failings and learn from them, will become evident. :slight_smile: