What in the name of all that is holy is wrong with my code?


5. Pull it together

trip_cost('Tampa', 0) raised an error: unsupported operand type(s) for -: 'str' and 'int'

I've seen every other person's questions and cose and mine is no diffferent but it won't work

def hotel_cost(days):
    return 140 * days
def plane_ride_cost(location):
    if location == "Charlotte":
        return 183
    elif location == "Tampa":
        return 220
    elif location == "Pittsburgh":
        return 222
    elif location == "Los Angeles":
        return 475

def rental_car_cost(days):
    cost = 40 * days
    if days >= 7:
         return cost - 50
    elif days >= 3:
         return cost - 20
         return cost
def trip_cost(days, location):
    return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(location)


The first argument is 'Tampa', what does your function do with the first argument?

You can also call your function the same way as the error message mentions, that way you get a line number where you can insert print statements to investigate what is happening at that time that causes the crash.


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