Question "Python Control Flow" exercise

Hello everyone,

I’m working on the “Python Control Flow” exercise Sal’s Shipping and I do not understand why my code returns an error:

my code:

def grd_ship_cost(weight):
if weight < 2.0:
cost = weight * 1.50 + 20.0
elif weigth <= 6.0:
cost = weight * 3.00 + 20.0
elif weight <= 10.0:
cost = weight * 4.00 + 20.0
else: cost = weight * 4.75 + 20.0
return cost

print(grd_ship_cost(8.4))

error:
Traceback (most recent call last):
File “script.py”, line 11, in
print(grd_ship_cost(8.4))
File “script.py”, line 4, in grd_ship_cost
elif weigth <= 6.0:
NameError: name ‘weigth’ is not defined

Thank you for your support!
Roland

this is the useful part of the error:

elif weigth <= 6.0:
NameError: name ‘weigth’ is not defined

i know it looks terrifying, but as you can see weigth is undefined, that is because you made a small typo

1 Like

oh my god… thank you so much … didn’t see it.

1 Like