Taking a vacation : putting all together (my codes compile shows error)


def hotel_cost(days):
        return 140*days 
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:
        return cost - 50
    elif days >=3:
        return cost - 20
    return cost
def trip_cost(days, city):
        sum=hotel_cost(days) + plane_ride_cost(city) +                 rental_car_cost(days)
        print sum
        return sum
#ends here        


print if you wish to see any output.

print trip_cost(2,"Tampa")


you call the function like this:


however, the exercise will also call your function multiply times (to see if the code works), but they provide the city as first argument, and days as second argument, so in your function declaration:

def trip_cost(days, city):

you should swap your parameters (city,day)


thanks a lot sir it solved my problem thanks you sir