"Pulling it Together" Error


#1

I am stuck on "Pulling It Together" (https://www.codecademy.com/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096#)

Whenever I run this code, calling the trip_cost function or no, I get the error message: Oops, try again.
trip_cost('Charlotte', 4) returned None instead of the correct value 883

The city and number change from try to try.

I couldn't see any stupid mistakes (if instead of elif, misspelled variable names, etc.)


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

def trip_cost(city, days):
    rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

trip_cost("Los Angeles", 14)

If anybody can diagnose the problem, then thank you in advance.


#2

missing return.

return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)

#3

2 posts were split to a new topic: Not printing the value to the console


#4

Thanks! I am about to try it now, but I have no doubt it'll work. :slight_smile:


#5

A post was split to a new topic: Idk whats wrong with my code: