Hey, You Never Know! error message


I used this code, and did what was told, and I also looked through everyone's question on the same lesson and I did what everyone said to do, and it still turned out wrong.


The error message that pops up is trip_cost('Pittsburgh', 5, 0) raised an error: global name 'spending_money' is not defined

But I followed all the directions, I'm not sure why adding spending_money isn't working.

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):
    cost = days * 40
    if days >= 7:
        cost -= 50
    elif days >= 3:
        cost -= 20
    return cost
def trip_cost(city, days, spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money


Hi you are at the wrong lesson you are at Before We Begin but you code is for this lesson Hey, You Never Know! .. I try your code and it works fine..


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