Plan your Trip!


Traceback (most recent call last):
File "python", line 27, in
File "python", line 26, in trip_cost
NameError: global name 'hotel_cost' is not defined

Replace this line with your code. 
def hotel_costs(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):
    rental_cost = 40*days
    if days >= 7:
        return 40*days-50
    elif days >= 3:
        return 40*days-20
        return rental_cost
def trip_cost(city,days,spending_money):
        return rental_car_cost(days) + plane_ride_cost(city) + hotel_cost(days) + spending_money
print trip_cost("Los Angeles", 5, 600)


Your error is pretty simple. You name your hotel function hotel_costs but use hotel_cost on this line.

Make sure to keep the function names the same, or the smallest mistake can trip up your entire code.


look your indentation ,
the print it should be at first


Which line are you talking about?


print line
print trip_cost("Los Angeles", 5, 600)


The print statement is fine for that line :confused: His problem is that he spelled hotel cost wrong in the return statement of the last function.


i;m sorry chip


You're fine. :slight_smile: Just didn't want the original poster to be misleaded.


i bad in english language :slight_smile:


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