Upgraded Shipping Exercise

Upgrading Shipping Exercise
I was trying to take the shipping exercise one step further and have it print only the cheapest option, and then the fastest option. I simplified the shipping rules for speed but I can’t seem to get it to print the fastest option(for mine it would always be Second Day Air). It is ONLY printing the cheapest. HELP!

Try removing the indent on your last print statement:

# print lowest shipping $
if ss < ps and ss < sda:
    print("Cheapest Shipping: Standard $", ss)
elif ps < ss and ps < sda:
    print("Cheapest Shipping: Premium $", ps)
elif sda < ss and sda < ps:
    print("Cheapest Shippping: Second Day Air $", sda)

# This should print now:
print("Fastest Shipping $", sda)

You can also simply your Standard Shipping calculation:

# standard shipping
if weight < 1:
    ss = weight * 1 + 5
else:
    ss = weight * 2 + 5

Let me know if this resolve your issue.

2 Likes

That fixed it! I was planning on writing more options for shipping and that’s why I used elif. Oddly enough, when I tried to use else it gives me an error… This is a non issue but I’m interested now why I get the error. I saved it if you want to take another look.

The else statement results in a SyntaxError!
The correct syntaxe for else woould be:

if something:
   do something 
else:
   do something different

If you have any other questions, feel free to ask!