Pull it Together

#1

hotel_cost(1) raised an error: maximum recursion depth exceeded

I didn't rise recursion depth but it's still writing that i did

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

#2

you call the function inside the function:

if hotel_cost(nights) == 140:

this will cause recursion, given there is no base case, this will reach maximum recursion depth. Please revise your if condition

#3

Stupid mistake. Thanks.

#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.