Sal`s shipping Code problem

weight = “8.4”


if weight <= 2:

cost_ground = weight * 1.5 + 20

elif weight <= 6:

cost_ground = weight * 3.00 + 20

elif weight <= 10:

cost_ground = weight * 4.00 + 20


cost_ground = weight * 4.75 + 20

print(“Ground Shipping $”, cost_ground)

Im new in programming. Can anybody help with that code? It doesnt work and I could not find the mistake in it. Thank you.

It’s difficult to tell b/c the code isn’t formatted. What is the error?
Please use the “</>” button to format it (b/c Python relies on indentation).

Also, it might be a good idea to do a cursory search in the forums for an answer b/c this is a well-visited topic and might provide you with an answer/help you debug.

(in the absence of the “New User Guide” [and an excellent topic from a former CM called, "How to ask good questions (and get good answers!]) , the old one used to provide learners with this advice):

  • search for an answer before posting a topic

  • always include a link to the lesson

  • please post your formatted code.

See also here.

The value should be a number (float) so it can be compared to the other numeric values in the if statements.

1 Like