Taking a vacation 5. Pull it together


#1



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

trip_cost('Los Angeles', 7) returned None instead of the correct value 1685

How do I correct my code? I'm not sure where the problem is and I have been working on it for a while.


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


#2

your trip_cost function stores the result in a variable total. The hint is in the error message:
trip_cost('Los Angeles', 7) returned None instead of the correct value 1685

Let me highlight that for you. Returned, your function doesn't return anything, use the return keyword


#3

thank you for your help. such an obvious mistake. I've got it now