Help me pls


#1



ex 5/7 taking a vacation


Oops, try again. trip_cost('Pittsburgh', 7) raised an error: unsupported operand type(s) for -: 'str' and 'int'


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


#2

here:

 trip_cost('Pittsburgh', 7)

the city is the first arguments, and days the second argument, now look at your function:

def trip_cost(days, city) :

days is the first parameter and city the second parameter. In other words, days will contain Pittsburgh value and city will contain 7 as value, this causes problems


#3

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