I'm simply really confused here. The error reads:
Oops, try again. Your code looks a bit off. Feel free to peek back at earlier exercises if you need a refresher! Take a look at the console window for the error message from the interpreter.

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


Okay... What error does the interpreter give you?


You are going to run in to two problems here.

First, the main reason your code does not work, the trip_cost method.

You use the word sum, in conjunction with + for addition purposes. sum is a function and would be called by using sum(args). You do not need to call the function though, since you are already adding them together with +.

The second problem you will run into is that you attempt to call your hotel_cost method with the argument nights, which is not a defined variable in the code. So there should be something other than nights there.


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