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


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
        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?


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


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


@dawidrz87 solved your problem, right?

P.S. Formatting guide.