Why is my code not working


taking a vacation lesson 5

Oops, try again. plane_ride_cost('Los Angeles') returned None instead of the correct value 475

def hotel_cost(days):
    return (days*140)

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:
        return (price-50)
    elif days >= 3:
        return (price-20)
    elif days < 3:
        return (price)

def trip_cost(city, days):
    return (city+days+days)


Try capitalizing Angeles. It is searching for "Los Angeles" exactly with that capitalization. Make sure you have correct capitalization on EVERYTHING YOU DO.


i just tried that but its saying trip_cost('Pittsburgh', 0) raised an error: cannot concatenate 'str' and 'int' objects.


In your trip_cost function, do


This converts your ints to strings so they can be concatenated.


thanks, but it still doesn't work


Does your code throw the same error?


For the trip_cost you need the rental_car_cost(days), hotel_cost(days), and plane_ride_cost(city) functions.


it says:
File "python", line 23
def trip_cost(str(city) + str(days) + str(day)):
SyntaxError: invalid syntax


You can't add things within the parameters of a function. Add them outside as a variable and pass that variable if you really need it.


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