Do you agree with the error message?
If you read your function, if you execute it manually, in your head, what does rental_car_cost(3) then evaluate to? If you got the wrong answer (100) then you have understood your code correctly and should compare it with what it should be doing to get the correct result. If you got the correct result (120) then you’ve misunderstood your code and you might want to explain what you think it does so that someone can point out where you’re going wrong.
You’ll also want to take care to post code that is intact so that there is no doubt about exactly what your code looks like, to ensure that other people are seeing the same code as you’re having trouble with and to make it easy, inviting for others to help out.
I had the problem with the same error message but then I modified the code like this:
def rental_car_cost(days) :
cost = 40*days
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost
I have tried this code a few different ways and it doesn’t seem to work. I’ve been working on it for 2 days with no resolve.
I’ve even copied and pasted code that peoplehave posted as working and either get an error that I’m getting 120 instead of 100 or that there is a syntax error after my if statement. any help would be appreciated
def rental_car_cost(days):
return 40*days
cost = days * 40
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost
i’ve been trying all that’s been said and it still tells me “It looks like rental_car_cost returns 120 instead of the correct amount (100) for 3 days.” what am i doing wrong?