Any ideas?


#1

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 'NOPE'

def rental_car_cost(days):
    pago = 40 * days
    if days >= 7:
        pago -= 50
        return pago
    elif days >= 3:
        pago -= 20
        return pago
    else:
        return pago

def trip_cost(city,days):
    return sum(sum(hotel_cost(days)+rental_car_cost(days))+plane_ride_cost(city))

Oops, try again. trip_cost('Los Angeles', 5) raised an error: 'int' object is not iterable


#2

the sum of the sum, how does that work?


#3

:cry:

def trip_cost(city,days):
    return sum(hotel_cost(days)+rental_car_cost(days)+plane_ride_cost(city))

Oops, try again. trip_cost('Pittsburgh', 1) raised an error: 'int' object is not iterable


#4

i am not paying attention. sum() is to get the sum of an iterable, like a list.

integers are not iterable. just use + to add integers together, don't use sum() at all


#5

I love you :heart_eyes:


#6