#5 please help "Maximum recursion depth exceeded"


#1

5 please help

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

def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    if city == "Tampa":
        return 220
    if city == "Pittsburgh":
        return 222
    if city == "Los Angeles":
        return 475

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

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

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


#2

You are calling the hotel_cost function from within the function itself. How do you plan to ever break out of that?

Think about that a bit. What do you really want to return?


#3

Thanks for the heads up. Just wondering why on previous problem it allow me to move on


#4

I'm afraid that I can't give you a good answer to that!

I like to think of the code checker as lazy, but it is just a tool and a human has to program it. The programmer likely didn't think of every possible problem.


#5

don't include function name. It should be
return 140*nights