Im having trouble with the hotel cost please help


i'm getting the error maximum depth recursion exceeded for the hotel_cost please someone help.

def hotel_cost(nights):
    return hotel_cost(nights*140)
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):
        cost = 40 * days
        if days >= 7:
                cost -= 50
        elif days >= 3:
                cost -= 20
        return cost
def trip_cost(city, days):
    return hotel_cost(days) + rental_car_cost(days) + plane_ride_cost(city)


The above is an infinite recursion (a function that calls itself with no end).

def hotel_cost(nights):
    return 140 * nights

This is a common error made by beginners. It would be a good idea for you to go back and review variables, loops and functions a little closer so it is clear in your mind how to avoid recursion and infinite loops.


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