Pull it together


#1

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

can anyone tell me what I need to fix this?
I keep getting an error that says:

"Oops, try again. hotel_cost(1) raised an error: maximum recursion depth exceeded "

I tried some of the options to correct this on the forums but still keep getting an error.
there was a screen shot from someone who did the same thing but didn't get the error I was getting.


#2

can you post your full code? The problem is in your hotel_cost function (see error message), but you didn't post this function


#3

def hotel_cost(nights):
    print hotel_cost(nights)
    return hotel_cost(140)

def plane_ride_cost(city):
    print plane_ride_cost("Tampa")
    if city == "Charlotte":
        return plane_ride_cost(183)
    if city == "Tampa":
        return plan_ride_cost(220)

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

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

#4

here:

def hotel_cost(nights):
    print hotel_cost(nights)

you call the function inside the function, this known as recursive function calls, and unless you have a base case (which you don't) this goes on for infinity. (sort of like an infinity for loop but slightly different)

same for plane_ride_cost


#5

ok. when I entered it in the previous lessons it let me pass so I assumed all was right.
I got it now, thanks!


#6