# Taking a Vacation - Putting it together

#1

I keep getting the same error (Oops, try again. trip_cost('Tampa', 6) raised an error: 'int' object is not callable ) when I try and submit the code. This doesn't happen for other parts of this exercise even if that part of the code hasn't been changed.

Here is the rest of the code:

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

cost = 40*days

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):

rental_car_cost = 40*days

if days >= 7:

rental_car_cost -= 50

elif days >= 3:

rental_car_cost -= 20

return rental_car_cost

def trip_cost(city, days):

trip_cost = rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

return trip_cost(city,days)``````

It's worth noting that the specific error keeps changing between different cities when I attempt to re-submit the code.

#2

This is recursion. If you must use variables with the same name as their function, don't write them as function calls.

``return trip_cost``

#3

Thanks for the help - ill give this a try

#4

Here is the new code:
But it is still give an error:

Oops, try again. trip_cost('Pittsburgh', 3) raised an error: 'int' object is not callable

even though the function "trip_cost" has been redefined as "trip_total"

``````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):

rental_car_cost = 40*days

if days >= 7:

rental_car_cost -= 50

elif days >= 3:

rental_car_cost -= 20

return rental_car_cost

def trip_total(city, days):

trip_total = rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

return trip_total(city,days)``````

#5

I have also made the correction from 'return trip_total(city,days)' to 'return trip_total' when calling the function

#7

A post was split to a new topic: Need help getting past this

#9