Cannot concatenate 'str' and 'int' objects


#1

I don't understand what is going on. I've followed the instructions. Can anyone point me to the correct way trip_cost should look like?

I understand you cannot add str and int together but why did the tutorial lead me down this path? I don't know how to fix it, I've tried adding str() and or int() in front of all variables under trip_cost it still doesn't work.

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

Oops, try again. trip_cost('Tampa', 3) raised an error: cannot concatenate 'str' and 'int' objects
Oops, try again. trip_cost('Pittsburgh', 0) raised an error: cannot concatenate 'str' and 'int' objects
Oops, try again. trip_cost('Charlotte', 6) raised an error: cannot concatenate 'str' and 'int' objects


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


#2

in trip_cost, you need to call the function you build earlier to get the cost of flight ticket, the cost for renting a car and the cost for days you are going away, see step 2 of the instructions


#3

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