I need to print a "Float"

I have a float that needs to print, I have not learned in the lessons, as far as I know how to get around this other than copying code that I do not yet comprehend to complete the project. The error message says it can’t print a float.

print = "Ground Shipping"

if weight <= 2:
 cost_ground = weight * 1.5 + 20
elif weight <= 6:
 cost_ground = weight * 3.0 + 20
elif weight <= 10:
 cost_ground = weight * 4.0 + 20
elif weight >= 10:
 cost_ground = weight * 4.75 + 20

there is also a weight = 8.4 at the head of this code…at the end of the code it says: Traceback (most recent call last):
File “shipping.py”, line 13, in
TypeError: ‘str’ object is not callable

One problem is

print = "Ground Shipping"

You used print as a variable (the string "Ground Shipping")
and then you tried to use print as a function

You have to change the variable’s name to something else (or otherwise change that line)
so that when you do print(cost_ground),
it does not try to use the variable (that now contains a string)

1 Like

Thanks soo much, I was supposed to comment the ground shipping, and not use print. Thank you!

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.