Taking a vacation rental car


def hotel_cost(nights):
return 140 * nights

def plane_ride_cost(city): #Not sure why this isnt defined
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):
return 40 * days
if days >= 7:
cost = (days * 40) - 50
return cost
elif days >= 3:
cost = (days * 40) - 20
return cost


I've been trying at this for about an hour and I still can't get it. I've searched everyone's post in the questions thing and none of them work. HELP!


This will always return the same thing... days times 40. Set a variable to this amount instead, then adjust it in the if..elif statement.

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

Now there is just one return statement at the end of the function.


@mtf i thought you should initialize days? i.e. set days = 0 first?


Then the return value would always be zero since we are multiplying. days is the parameter and the argument is a natural counting number from 1 to something. It's the value being checked against the discount range, 7 or more, elif 3 or more.


it says indentation error line 16, but I don't know what the problem is. Can you send a copy of the correct answer and an explanation of the difference between the correct and mine?

Thank you guys so much for the help



If you remove this line, your code (assuming indentation is correct) will work fine. Paste the above line back into the bottom of the function, after an, else:.