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


#1

Here is 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):
    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_cost(city) + rental_car_cost(days))
    return sum

I keep getting the error:

Oops, try again. trip_cost('Pittsburgh', 7) raised an error: global name 'nights' is not defined
This error accors with a different city each time i run it.
Any ideas?


#2

Try with changing nights in this part

into days
Also remember to put your code with indents. To do that paste your code, highlight it and press Ctrl + Shift + C


#3

It was a few formatting mistakes, only reason there is no indentation on here is the forum editor removes it. Thanks


#4

@dawidrz87 solved your problem, right?

P.S. Formatting guide.