5/8 "Pull it together"- Please help!


#1

I get the error thrown at me: Oops, try again. hotel_cost(1) raised an error: maximum recursion depth exceeded
My code is:

def trip_cost(city, days,):
    def hotel_cost(nights):
        return 140 * nights
    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

I do not know where i am going wrong. please help me :smiley:


#2

Here is the code.

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):
    rental_car_cost = 40 * days
    if days >= 7:
        rental_car_cost -= 50
    elif days >= 3:
        rental_car_cost -=20

    return rental_car_cost

def hotel_cost(days):
    return 140 * days

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

#3

Thank you very much. I was stuck on this for a long time :smiley: