I am getting error as Oops, try again. trip_cost('Pittsburgh', 0) raised an error: 'int' object is not iterable


def hotel_cost(nights):
    return nights*140
def plane_ride_cost(city):
    if city == "Charlotte":
        return int(183)
    elif city == "Tampa":
        return int(220)
    elif city == "Pittsburgh":
        return int(222)
    elif city == "Los Angeles":
        return int(475)
def rental_car_cost(days):
    cost = 40*days
    if (days >= 7):
        cost = cost-50
    elif (days >= 3):
        cost = cost-20
    return cost
def trip_cost(city,days):
    return sum(rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city))


This isn't how you use sum().

If you want to add those three numbers together then just add them.

sum() adds the items of an iterable, for instance, a list.


A post was split to a new topic: rental_car_cost(3) returned 120 instead of the correct value 100