# Help With My Problem Set: Sal's Shipping

Hey guys, if this is formatted incorrectly, I apologize, feel free to remove, and I’ll give the ‘format it’ link another look.

That being said when I am solving this problem, when I get into the lower weight of the shipped items, something goes wrong and I am not sure what exactly it is. When I set ground shipping and drone shipping weights to 1, I am returned with 24, and 12 respectively. I have gone through both of them numerous times and cant seem to find what I am missing, or where I am going wrong.

This also may not be the most efficient, or best way to tackle this, but I’m in my first few hours of Python, so take it easy on me!

Appreciate any insight!

#Ground Shipping
weight = 1
if weight > 10:
cost_ground = 4.75 * weight + 20
elif weight <= 10 > 6:
cost_ground = 4.00 * weight + 20
elif weight <= 6 > 2:
cost_ground = 3.00 * weight + 20
else:
cost_ground = 1.50 * weight + 20
print("Standard Ground Shipping: \$",cost_ground)

#Drone Shipping
weight = 1
if weight > 10:
cost_drone = 14.25 * weight + 0
elif weight <= 10 > 6:
cost_drone = 12.00 * weight + 0
elif weight <= 6 > 2:
cost_drone = 9.00 * weight + 0
elif weight < 2:
cost_drone = 4.50 * weight + 0
print("Drone Shipping Cost: \$",cost_drone)

I’m just taking a guess, but
maybe changing
elif weight <= 10 > 6:
to
elif 6 < weight <= 10:
and similar may help (but I don’t actually know what counts as valid syntax for these kind of conditionals in Python)

1 Like
elif weight <= 10 and weight > 6:

what your code is doing currently is comparing 6 to 10 and not to weight. So in regular language…
If Weight is less than or equal to 10, 10 is greater than 6 - what your code is saying
If Weight is less than or equal to 10 and weight is greater than 6 - what the code should be saying.

Also, since the flat rate of ground shipping is \$20, you can make a variable before your if statement of cost_ground = 20 and then use += in your if loop.

1 Like