Hey you never know! :@


#1

Hi, ive been having trouble with my code.

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,spending_money):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city)
    + spending_money

print trip_cost ("Tampa", 13, 75)

It says : Oops, try again. trip_cost('Pittsburgh', 5, 76) returned 1102 instead of the correct value 1178

{ Instructions
Modify your trip_cost function definition. Add a third argument, spending_money.
Modify what the trip_cost function does. Add the variable spending_money to the sum that it returns.}

What did i do wrong ? I've searched many posts with the same topic but couldnt understand my mistake.

Thankyou!


#2

this:

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

should be one line, seems it are currently two lines

it would perfectly explain the error: 1102 + 76 is 1178


#3

omg that really worked.. that was really stupid.

Thanks.


#4