4/7 syntax looks good to me but will not execute!


#1

Why wont this code run? No one can tell me so far.


#2

Lines 20 through 24 are not needed for excersize 4/7
also you need an

else:
    return cost

after the return cost - 20 so if you stay for less than 3 days it will give you the regular cost


#3


pls tell the error


#4

can you x out of that error so i can see the rest of the code


#6

def hotel_cost(nights):
return 140*nights

def plane_ride_cost(city):
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475
this is what I put and it worked :smile:
def rental_car_cost(days):
cost = days*40
if days >= 7:
cost -= 50
return cost
elif days >= 3:
cost -= 20
return cost
else:
return cost


#7

Hi @mananjain0220 ,

Let us see the remainder of your code, as @ryebread4 asks.

In the meantime, you need to fix the indentation. In the if structure within the plane_ride_cost function, you only indented the return statements by one space past the block headers. While this did not cause the error, you should go four spaces past the block headers instead.

Line 15 in the rental_car_cost function is indented by seven spaces, when it should be four. That is why you got an error regarding line 16. That line is indented by the right amount, but caused an error because it does not match line 15.