Sal's Shipping, There is a None in the Result

Hi guys

i have a problem when running my code, I got the correct answer but there is a None in the display
this is my code, thank you

function for ground shipping

def ground_shipping (weight, cost= 20 ):

if weight <= 2:

return (weight * 1.50) + cost

elif weight >= 2 and weight <= 6 :

return (weight * 3.0) + cost

elif weight >= 6 and weight <= 10 :

return (weight * 4.0) + cost

return (weight * 4.75) + cost

premium_ground_shipping = 125

function for drone shipping

def drone_shipping (weight, cost = 0):

if weight <= 2:

return (weight * 4.50) + cost

elif weight >= 2 and weight <= 6 :

return (weight * 9.0) + cost

elif weight >= 6 and weight <= 10 :

return (weight * 12.0) + cost

return (weight * 14.25) + cost

def shipping_cost (weight):

ground = ground_shipping (weight)

premium = premium_ground_shipping

drone = drone_shipping (weight)

if ground < premium and ground < drone:

method = 'standard ground'

cost = ground

elif premium < ground and premium < drone:

method = 'premium' 

cost = premium


method = 'drone' 

cost = drone

print (

"The Cheapest Option Available is $%.2f with %s shipping."

% (cost, method)





First off, use the “</>” button to format your code. When you do that, the code is much easier to read.

I am still kind of a noob at Python, but I see a logic problem with your code.

In this part, you wrote if weight <= 2, but also elif weight >= 2. As a result, 2 goes into both of these loops, and that probably causes an error.

According to this logic, fix all the similar problems and see if it works.

Again, I am still a noob so this might not fully fix the problem.

1 Like

Thank you for your advice
I try it but still the output is this

The Cheapest Option Available is $34.40 with standard ground shipping.
The Cheapest Option Available is $125.00 with premium shipping.

I’m sorry, I really am not sure :slightly_frowning_face:

1 Like

Or not, since every case has a return

That is printing the result of the print statement in your function. Have your function return instead of print…


That okay, thank you for your help

Okay i try to change it to one return in every function

It only needed to be changed in the one above.