Hey, You Never know - trip_cost after adding spending_money


#1



I'm having problems after adding the function for spending_money. Any help is much appreciated!


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


ERror message - Oops, try again. trip_cost('Tampa', 8, 0) returned 2090 instead of the correct value 1610


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


#2

Pay close attenttion to what the instruction wants you to do. You shouldn't create a spending_money function it should just be an argument in your trip_cost function.


#3

And before trip_cost function try arranging your code like this. :slight_smile:

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