Elif is throwing error

Below code is throwing error in the editor saying “invalid syntax” .
am going out of my brains , i could not find what mistake am doing .
could anybody please help me here

def ground_shipping(weight):
   if weight <= 2:
      cost= 1.5
  elif weight <= 6:
      cost=3

error

File “script.py”, line 6
elif weight <= 6:
^
SyntaxError: invalid syntax

Thanks,
Python Beginner

Is that your full code? Usually it’s either if, elif, else, or omitting the elif if you’re just checking one condition.

Make sure to check your indentation, as well. It looks like your elif line is a space off and Python is rather strict in that regard.

it’s a space issue … which i figured out by using reindent.py .
Thanks for ur response

1 Like