Pull it together , error


#1



https://www.codecademy.com/en/courses/python-beginner-P5YtY/1/4?curriculum_id=4f89dab3d788890003000096#


this error appeared now and when i click submit it mentions other citys
Oops, try again. trip_cost('Los Angeles', 7) returned 705 instead of the correct value 1685


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


#2

These lines can all be removed.


#3

that was the only solution i could do for the previous excercise, i just removed them and tried to run the code it still indicates the error


#4

So is this what you have now?

def rental_car_cost(days):
    cost =days*40
    
    if days >=7:
        cost -= 50
        
    elif days >= 3:
        cost -= 20
        
    return cost

#5

yes but i couldnt get it to work so i added the other two elif


#6

The code looks fine, now. What error message are you getting?


#7

Oops, try again. trip_cost('Los Angeles', 7) returned 705 instead of the correct value 1685


#8

Remember to include hotel_cost(days) in the trip_cost function.

705 + 980 == 1685

#9

Oops, try again. trip_cost('Tampa', 6) raised an error: global name 'nights' is not defined

this error came up now and nights has been identified


#10

Be sure you do not try to call hotel_cost() with nights, but days since that is the parameter of the trip_cost function. nights is local to the hotel_cost function, only.


#11

you are a genius thank you so much


#12