Taking a vacation #6


#1



For some reason when i add spending_money to the code it stops giving me the correct sum.


Oops, try again. trip_cost('Charlotte', 9, 40) returned 1753 instead of the correct value 1793


Replace this line with your code. 
def hotel_cost(nights):
    
    return 140 * nights
    
def plane_ride_cost(city): 
    
    if city == "Charlotte": 
        return 183
        
    if city == "Tampa": 
        return 220
            
    if city == "Pittsburgh": 
        return 222
                
    if city == "Los Angeles":
        return 475

def rental_car_cost(days):
    
    cost = 40 * days
    
    if days >= 7:
        return cost - 50
        
    elif days >= 3 and days <=6:
        return cost - 20
    
    else:
        return cost
        
def trip_cost(city, days, spending_money):

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


#2

is this line:

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

one line? it doesn't look like it


#3

it wouldnt allow me to make it all one line


#4

but it has to be one line:

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

#5

ok thank you for your help


#6

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