# FAQ: Taking a Vacation - Transportation

``````def rental_car_cost(days):

cost = days * 40

if days >= 7:

cost -= 50

elif days >= 3:

cost -= 20

return cost
``````

i type the write code but i somehow always seem to get errors. when i check the solution its exactly the same as mine

the equal(=) sign goes after the minus(-) sign.

I think the error is from your Indentation on line 14. you did space then def … when it shoud be no space

This might be caused by improper Indentation. maybe you had too little or too much space

What is wrong with my code? It’s the bottom exercise in the pic that says #Transporation Exercise 4
Thanks in advance for all the help.

`cost -= 50` is essentially `cost = cost - 50`. However, you can’t return assignment statements (`=` is called the assignment operator). Knowing this, can you solve it?

I’ll keep your answer in mind when attempting to solve this. It was very helpful. Thank you so much 1 Like

I have a question… so if cost = cost - 50 or cost -= 50, why can’t cost = days * 40?
In math, I would multiply \$40.00 by the number of days spent with the vehicle.

seems possible, why would this not be possible?

2 Likes

If what @stetim94 said isn’t applicable, I think you’re referring to the following line.

``````return cost = days * 40
``````

Again, `cost = days * 40` is an assignment statement and therefore cannot be returned. We can’t return any statement that uses the `=` operator.

1 Like

ok that made sense. Thank you both very much for the help @stetim94 @victoria_dr

1 Like

i checked the solution for the code because idk anymore why the code isnt working. i checked the code and they have the exact same text (see image). why does python still think my code is incorrect?

I want to know how the program calculates the 50% and 20% in the function def rental_car_cost adding ( cost -= 50 )

My original solution was …

``````def rental_car_cost(days):

cost = days*40

if days >= 7:

cost = (days*40)*0.50

elif days >=3 and days < 7:

cost = (days*40)*0.20

return cost
``````

Why this is wrong??

it doesn’t, because this was not the requirement of the exercise

The discount simply is a fixed amount (50 dollars for more then 7 days and 20 dollars for more then 3 days)

1 Like

this program isn’t working the way I expected:
return 42
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

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

elif days >= 3 and days < 7: I also tried it without the ‘and’ part it still didn’t work. I checked the solution took out the ‘and’ days < 7: part still not working. replaced with the solution ( noticing that both codes were the same. Is there a problem with the checking program?