Taking a vacation 4/7(What's wrong with my code?)



Hi everyone,
I don’t know what’s wrong with my code but it keeps saying the it returns outside the function? can anyone give me a hint help me solve the question? thank you so much!!

<do not remove the three backticks above>


There are lines in that last function that need indentation.


Hi, @megacoder47229,

The error you are receiving has to do with how you indented your code within the following function:

def rental_car_cost(days):
    cost = days * 40
if days >= 7:
    cost -= 50

elif days >= 3:
    cost -= 20
return cost

You are using improper syntax. The if, elif, and return statements should all be on the same indentation level as cost = days * 40. The way it is indented now, those statements are outside of the function.


Is this what you mean? but after I put them on the same level then there’s another error.


my question is why it keeps saying that it return outside the function?
and even after I put indentation for the last couple lines there’s still problem


Why do you have a random white space between your if and elif statements?

  if days >= 7:
    cost -= 50

  elif days >= 3:
    cost -= 20

Please remove it.


problem solved!! Thank you so much!!


2 posts were split to a new topic: 4/7 transportation