Expected an indented block

Hello! im working on Sal´s shipping When i try to save the code

def shipping_cost_ground(weight):

if weight <= 2:

price_per_pound = 1.50

elif weight <= 6:

price_per_pound = 3.00

elif weight <= 10:

price_per_pound = 4.00

else weight > 10:

price_per_pound = 4.75

return 20 + (price_per_pound * weight)

print(shipping_cost_ground(8.4))

im getting “expected an indented block” at line 3, how can I fix this? Leaving a image of my code aswell !
image|690x319

From your image it looks like you’ve indented the if statements and clauses correctly but not the body of your function which must also be indented.

So what would i need to change?

Your entire function should also be indented, the -> are used for illustrative purposes below, you should use spaces for your indents (cc seems to use two spaces for a each level of indentation so you may have to stick with that).

def myfunc(num):
-> if num > 10:
---> return True
-> else:
---> return False
# Without the -> (note the function body is indented)
def myfunc(num):
  if num > 10:
    return True
  else:
    return False


# No indentation here and therefore not part of the function.
result = myfunc(5)

Note that all code relating to the function is indented following the definition.

2 Likes