Plan your trip!


#1




Traceback (most recent call last):
File "python", line 25, in
File "python", line 23, in trip_cost
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'


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

print trip_cost("los Angeles", 5, 600)

what is wrong with my code? please help


#2

your function call:

print trip_cost("los Angeles", 5, 600)

make sure to spell the city correctly (strings are case sensitive), otherwise plane_ride_cost won't return an integer


#3

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