Pull it Together


#1



Hello , I m stuck at this exercise . I m constantly getting this error
Oops, try again. rental_car_cost(1) returned 20 instead of the correct value 40

I dont know what to change.
Even if i call the function at the end i get the same message .

Can anyone help me please ?


def hotel_cost(days):
    return 140 * days
    
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 = 40 * days
    if days >= 7 :
        return - 50
    elif days >= 3 and days <7 :
        
    return - 20 
    
def trip_cost(days , city ):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)


#2

The first line is correct, and a good place to start.

We cannot subtract a number from a Python command (return is command). Add cost in there to fix this.

return cost - 50

and at the end,

return cost

so the non-discounted amount is sent back by default

You could also consider just changing cost in the if..elif and having a single return statement at the end.

cost -= 50

Since 7 has already been tested, we only need,

elif days >= 3:

#3

Thank you !
I modified it .
But still the same error .
Oops, try again. rental_car_cost(1) returned None instead of the correct value 40

What is wrong with rental_car_cost ?


#4

It sounds like didn't add the final return cost statement.


#5

My code is like this now , still the same error .

def rental_car_cost(days):
    cost = 40 * days
    if days >= 7 :
        return cost - 50
    elif days >= 3  :
         return cost - 20
    
def trip_cost(days , city ):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
    return trip_cost( "Los Angeles" , 4 )

#6

Add one more return statement to rental_car_cost.

elif ___:
    return ___
return cost

And this line,

Should not be a return statement, but a call to the function from global scope (no indentation).


#10