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


#1


https://www.codecademy.com/en/courses/learn-python/lessons/taking-a-vacation/exercises/transportation-?action=lesson_resume&link_content_target=interstitial_lesson

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!!

```python
<do not remove the three backticks above>

#2

There are lines in that last function that need indentation.


#3

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.


#4


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


#5

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


#6

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.


#7

problem solved!! Thank you so much!!


#8

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


#9