Plan your Trip


#1

Hi everyone
I'm stuck at this exercise :
https://www.codecademy.com/courses/python-beginner-P5YtY/1/6?curriculum_id=4f89dab3d788890003000096#

Here is the error message I get when running my program :

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

I don't understand because I printed my values and they are all integers so it should work

So here is my code :


def hotel_cost(nights) :
    cost_hotel = 140 * nights
    print cost_hotel
    return cost_hotel
    
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_car = 40 * days
    if days >= 7 :
        cost_car -= 50
    elif days >= 3 :
        cost_car -= 20
    print cost_car
    return cost_car
    
def trip_cost(city, days, spending_money) :
    a = hotel_cost(days)
    b = plane_ride_cost(city)
    c = rental_car_cost(days)
    d = spending_money
    return a + b + c + d
    
print trip_cost("Los_Angeles", 5, 600)


`

So tell me what you think ! Thx to you all


#2

You've misspelled city name in final line of code.


#3

oh ... right .. thx :smile:


#4

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