5. Pull it Together

#1

I am stuck on this exercise.

My code is:

``````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:
cost = cost - 50
elif days >= 3:
cost = cost - 20
return cost

def trip_cost(days,city):
return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days)``````

The error I get is:

``````Oops, try again.
rental_car_cost(1) returned None instead of the correct value 40``````

I don't know how to correct it.

#2

currently, your rental_car_cost function only reaches a return keyword if `elif` is evaluated to true. personally, given you update cost, the simplest solution would be to change the indent of return cost, so it reached in all cases at the end

#3

I changed the indentation so it was directly under `elif`:

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

but now I get the error:

``````Oops, try again.
trip_cost('Charlotte', 7) raised an error: unsupported operand type(s) for -: 'str' and 'int'``````

which, when I re-save & submit it, changes to:

``````Oops, try again.
trip_cost('Los Angeles', 3) raised an error: unsupported operand type(s) for -: 'str' and 'int'

Oops, try again.
trip_cost('Los Angeles', 8) raised an error: unsupported operand type(s) for -: 'str' and 'int'

Oops, try again.
trip_cost('Pittsburgh', 1) raised an error: unsupported operand type(s) for -: 'str' and 'int'``````

and so on.

#4

``def trip_cost(days,city):``

now look at the function calls:

``trip_cost('Pittsburgh', 1)``

your parameters appeared to be swapped

#5

Thank you very much!

#6