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


#1

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
    else:
        return "City not found"
def rental_car_cost(days):
    if days >= 7:
        return (days*40)-50
    elif days >= 3:
        return (days*40)-20
    else:
        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)


#2

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


#3

thanks
im such a dumbass


#4

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