Why is my code not working


#1



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)


#2

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


#3

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


#4

In your trip_cost function, do

str(city)+str(days)

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


#5

thanks, but it still doesn't work


#6

Does your code throw the same error?


#7

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


#8

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


#9

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.


#10

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