Taking a Vacation (Transportation) problem


#1

the error:

An error was raised for rental_car_cost(1): global name 'rent_cost' is not defined

my code:
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):
        rent_cost == 40 * days
        if (days >= 7):
            rent_cost - 50
        elif (days >= 3 and days<7):
            rent_cost -20
        elif (days<3):
            return rent_cost

any explanation please...appreciated


#2

The above is a comparison. Write it as an assignment:

rent_cost = 40 * days

`
rent_cost -= 50

Likewise the next one, too.

Not needed.

return is exclusive to the last case, which means the previous two cases return None. The last case can be removed.

cost = ____
if ( ... ):
    cost -= ___
elif ( ... ):
    cost -= __
return cost

#3

I really appreciate your effort, but after I fix it all. I got this.

Oops, try again. Did you create a function called rental_car_cost?


#4

Did you accidentally remove the top line of the function (def ...)?


#5

no, it was just the SPACE.

thanks a lot.