Taking a Vacation - Transportation


#1

def rental_car_cost(days):
cost = 40 * days
if days >= 7:
return cost - 50
elif days >= 3:
return cost - 20
return cost

It keeps saying oops, try again. Did you create a function called rental_car_cost for some reason.
Can anyone help me?


#2

def rental_car_cost(days):
cost = 40 * days
if days >= 7:
return cost - 50
elif days >= 3:
return cost - 20
else:
return cost

This should work!!!


#3

Have you made sure that rental_car_cost isn't in another one of your definitions?


#4

Yup!! its only function i have created


#5

Indent everything except the code inside the if statement, which should be indented twice.


#6

That did not work for me

What I typed in was this:

def rental_car_cost(days):
cost = 40 * days
if days >= 7:
return cost - 50
elif days >= 3:
return cost - 50
else:
return cost

the thing is, the message that came up was "Oops, try again.
Your code looks a bit off. Feel free to peek back at earlier
exercises if you need a refresher! Your code threw the following error:
'return' outside function (python, line 15)" and line 15 was "return cost - 50".

What's wrong with my code?

Thanks


#7

This worked for me:

def rental_car_cost(days):
----cost= 40 * days
----if days>=7:
--------cost-=50
----elif 7>days>=3:
--------cost-=20
----return cost

where ---- is one indent


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.