Sal's Shipping

Hi fellow coders.

I have encounter yet another dead end with my code in the following exercise:

https://www.codecademy.com/courses/learn-python-3/projects/sals-shipping

All of the first steps have been tested and worked. However for the last step I am having issues, the result keeps printing the premium cost no matter what weight I chose.

image

Any clues?

Hey there!

You are comparing ground, drone and premium. All of those are strings.

You’d rather want to compare the different costs, right?

3 Likes

Hi,

Yes I want to compare and return the cheapest cost depending on weight input.

1 Like

@barelyhere has pointed you in the right direction, by pointing out that for your variables ground, drone and premium

Does it make logical sense for a cost to be a string type? :slight_smile:

2 Likes

I makes no sense att all, thank you for that reminder.

I think however the reason they were in “str()” was because all the ground & drone functions were set as string because I added a print statement with a string and I needed to concatenate the strings and the interger result.
Anyhow, thank you again.

1 Like

So, you’re not using printf style formatting?

E.g.:

the_number = 3
the_quote = "First shalt thou take out the Holy Pin. Then shalt thou count to %s, no more, no less. %s shall be the number thou shalt count, and the number of the counting shall be %s." % (the_number,the_number,the_number)

print(the_quote)

which prints:

First shalt thou take out the Holy Pin. Then shalt thou count to 3, no more, no less. 3 shall be the number thou shalt count, and the number of the counting shall be 3.

(Yes, I know I’m repeating myself… but three is the number, after all…)

4 Likes

Five is right out! :rofl: :joy:

3 Likes

No I wasn’t, I know in the tutorial video it was shown. But I have no recollection that it was ever taught in the lessons so I skipped it

It’s definitely included in the Python 2 course, but I haven’t done the Python 3 one so can’t say for certain it’s in there.

Would be surprising if it’s not, it’s quite useful…