Hey, You Never Know! error message


#1



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.

https://www.codecademy.com/en/courses/python-beginner-P5YtY/resume?curriculum_id=4f89dab3d788890003000096


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


#2

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


#3

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