Pull it Together


hotel_cost is returning "none" instead of 140?

I've reworked hotel_cost a couple of different times. I keep coming up with this error :confused:

def hotel_cost(nights):
    total = 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):
    total = 40 * days
    if days >= 7:
        total -= 50
    elif days >= 3 and days < 7:
        total -= 20
    return total
def trip_cost(city, days):
    return hotel_cost(nights) + plane_ride_cost(city) + rental_car_cost(days)
    print trip_cost(5,'Tampa', 5)


This is normal, the function returns nothing.

Unless you want to do a procedure that directly modifies the value of total .... But in this case total should be rather a global variable not a parameter ...


So, should I set it as a return? I've done that, and now the cities raise errors as "nights" is not defined :confused:


can you please paste your new function hotel_cost() here?


Completed! I hope I pick up where I'm wrong at some point. Thanks so much for your help.


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