# Pull it Together

#1

Oops, try again.
plane_ride_cost('Charlotte') raised an error: maximum recursion depth exceeded while calling a Python object

``````def hotel_cost(nights):
return 140 * nights
def plane_ride_cost(city):
city = raw_input("What destination? ")
if city == "Charlotte":
return 183
elif city == "Tampa":
return 220
elif city == "Pittsburgh":
return 222
elif city == "Los Angeles":
return 475
return plane_ride_cost (city)
def rental_car_cost(days):
cost = 40 * days
if days >= 7:
cost -= 50
elif days >=3 :
cost -= 20
return cost
def trip_cost(city, days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
print trip_cost ("Tampa", 5)``````

How can i fix it?
Thank's.

#2

You call the function inside the function:

``````def trip_cost(city, days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
print trip_cost ("Tampa", 5) // this line, you call the function``````

you might want to put the function call outside the function:

``````def trip_cost(city, days):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
print trip_cost ("Tampa", 5)``````

Calling a function within a function is possible, and sometimes very useful, but you have to be careful, if there is no limit, the function will endlessly call itself, sort of infinity loop but slightly different. We call a function call inside a function a recursive function call, which explains the error

#3

Thank's, now i can input city, program return cost, and then i have the same error "Oops, try again.
plane_ride_cost('Charlotte') raised an error: maximum recursion depth exceeded while calling a Python object"

#4

because you have a very similar problem in that function? Again, you make a function call inside a function.

#5

thank's, i already fixed it