Hey, I started to learn Python on Codecademy a few days ago and it’s a lot of fun so far. Now I reached a point where I’m stuck.
It’s the “Sal’s Shipping” task here: https://www.codecademy.com/courses/learn-python-3/projects/python-sals-shipping
What I’m struggling with is, that I have to write an if / elif / else statement that includes things like this:
“Over 2 lb but less than or equal to 6 lb”
I just can’t figure out how I can write this, because of the “but”, because it’s two things.
Thank you!
I think I advanced a bit more, but the result I’m getting is still wrong. 
# Enter package weight here
weight = 8.4
cost_ground = 0
# Ground Shipping
if weight <= 2:
cost_ground = weight * 1.5 + 20
elif weight > 2:
cost_ground = weight * 3 + 20
elif weight > 6:
cost_ground = weight * 4 + 20
elif weight > 10:
cost_ground = weight * 4.75 + 20
print(str(cost_ground) + "$")
Hi there,
You can use logical operators (and, or) to assert more than one condition in a if / else if statement, for example:
“Over 2 lb but less than or equal to 6 lb” translates to:
if weight > 2 and weight <= 6
1 Like
Wow, thank you so much! Super helpful
1 Like