Hey, You Never Know!


#1


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

Error message states: "Oops, try again. trip_cost('Los Angeles', 2, 75) returned 985 instead of the correct value 910". I honestly do not know where I made a mistake. Any help is appreciated! :grinning:


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


#2

@chipsurfer69371 ,

You have this ...

spending_money *= days

... but the argument passed as spending_money represents the total amount of spending money for the trip, rather than the amount for each day. Therefore you should not multiply it by the number of days of the trip.


#3

Both of these lines can be removed.


#4

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