8.5 - Pulling it together issue


#1

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

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

Oops, try again. trip_cost('Pittsburgh', 5) raised an error: global name 'nights' is not defined


#2

Hi in your last return you didn't wrote plane_ride_cost(city) but plane_ride_home(city) and inside your hotel_cost(here) you should put days


#3

oops! Thanks! I did that in haste! I did make that correction, but still have the same error. Again, thanks for your quick response!


#4

it maybe a indent problem so her your code with indented

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

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

#5

Even though I had the indentation correct in the code (not here), I copied it over and it worked. Thanks!