Plan your Trip!


#1


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
    else:
        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)


#2

Hi,
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.


#3

look your indentation ,
the print it should be at first


#4

Which line are you talking about?


#5

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


#6

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.


#7

:smiley:
i;m sorry chip


#8

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


#9

i bad in english language :slight_smile:


#10

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