Taking a Vacation final exercise problems!


Pull it Together

Can someone please help me understand where I messed up with my code? It was working fine in all of the previous exercises.

Error: trip_cost('Tampa', 9) returned function trip_cost at 0x7fbf584f31b8 instead of the correct value 1790

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

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


Do not assign to a variable with the same name as the function, Better to just return that line and skip making a variable.

Same applies to the rental_car_cost function. Change the variable to something that will not conflict with the function name. cost comes to mind.


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