Sal's Shipping Only Printing the Premium Shipping Method

The weights which have the premium shipping as the cheapest shipping are the only weights which print the print statement. Otherwise, the program is not printing.

Please see this topic:

How to ask good questions (and get good answers)

without crucial information (like the code), its really difficult to tell what might be causing this problem

def ground_shipping(weight):
if weight < 2:
return weight1.5 + 20
elif weight <= 6:
return weight
3 + 20
elif weight <= 10:
return weight4 + 20
return weight
4.75 + 20
premium_ground_shipping = 125
def drone_shipping(weight):
if weight < 2:
return weight4.5
elif weight <= 6:
return weight
elif weight <= 10:
return weight12
return weight
def cheapest_shipping(weight):
ground = ground_shipping(weight)
drone = drone_shipping(weight)
premium = premium_ground_shipping
if ground < premium and ground < drone:
method = “standard ground”
cost = ground
elif drone < premium and drone < ground:
method = “drone”
cost = drone
method = “premium ground”
cost = premium
“The cheapest shipping method is $%.2f with %s shipping method”
% (cost, method)

One possible problem that could be surmised is that the print statement is confined to the else branch. That being the case, one would need to reduce the indentation so the statement follows all the if clauses.

That was the problem. Thanks!!!

1 Like