 # Hey, You Never Know!

Will anyone tell me whats wrong?
i get this error
trip_cost(‘Charlotte’, 8, 0) raised an error: unsupported operand type(s) for -: ‘str’ and ‘int’

my code:

``````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):
if days >= 7:
return 40 * days - 50

``````elif days >= 3:
return 40 * days - 20

elif days < 3:
return 40 * days
``````

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

Hi @ace_lebron ,

This is your `trip_cost` function …

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

Codecademy tests your function, based on the assumption that you have the parameters in this order: `city`, `days`, `spending_money`. Instead, you have them as `days`, `city`, `spending_money`.
The function should be revised, as follows …

``````def trip_cost(city, days, spending_money):
return rental_car_cost(days) + hotel_cost(days) + plane_ride_cost(city) + spending_money
``````
2 Likes

as having 3 parameter days, city and spending_money

Then in the call of your trip_cost =function=
you make the mistake of providing the arguments in the wrong order…

You used

``````trip_cost('Charlotte', 8, 0)
``````

which should have been

``````trip_cost(8,'Charlotte', 0)
``````

But as you are using the return statement in the trip_cost =function=
will return a number Value without Display.

The solution

``````print( trip_cost(8,'Charlotte', 0) )
``````

#===================================

``````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):
if days >= 7:
return 40 * days - 50
elif days >= 3:
return 40 * days - 20
elif days < 3:
return 40 * days

def trip_cost(days, city, spending_money):
return rental_car_cost(days) + hotel_cost(days) +\
plane_ride_cost(city) + spending_money
``````

``````#trip_cost('Charlotte', 8, 0)
print( trip_cost(8,'Charlotte', 0) )``````
1 Like

Thanks For replying, But i am still getting the same error.

Here is my code:

``````   def trip_cost(days, city, spending_money):
return rental_car_cost(days) + hotel_cost(days) +\
plane_ride_cost(city) + spending_money
print trip_cost(8,'Charlotte', 0)
``````

i Have tried everything, indented the code,change the order but nothing works as you will have to pass the Code-Checker tests…

def hotel_cost(days):
return 140 * days
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 = 40 * days
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost
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)

As a learning experience