Oops, try again. trip_cost('Tampa', 5) returned None instead of the correct value 1100


#1



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


Oops, try again. trip_cost('Tampa', 5) returned None instead of the correct value 1100


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


#2

1.) You don't want to use sum as a variable name as it is a built-in Python function.
2.) You don't want to set any variables here, just return everything(rental_car_cost, etc.)


#3

@jkm345: You just forgot to return the value calculated in trip_cost() .


#4

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