7. Plan Your Trip! - TypeError: cannot concatenate 'str' and 'int' objects


Whenever i click run i comes back with the error
Traceback (most recent call last):
File "python", line 23, in
File "python", line 22, in trip_cost
TypeError: cannot concatenate 'str' and 'int' objects

Please tell me what i have done wrong

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
        return "City not found"
def rental_car_cost(days):
    if days >= 7:
        return (days*40)-50
    elif days >= 3:
        return (days*40)-20
        return days*40
def trip_cost(city, days, spending_money):
    return plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + spending_money
print trip_cost("Los Angles", 5, 600)


Los Angles is not a vaild city, so your plane ride cost function returns a string. integer + string is not possible, that is why you get an error message


im such a dumbass


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