Need help with "Taking a Vacation: Hey, You May Never Know"


#1

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

and the error that I am facing is
Oops, try again. trip_cost('Los Angeles', 7, 0) raised an error: unsupported operand type(s) for +: 'int' and 'function'

any help would be appreciated. TIA!


#2

Hi @bitslayer89221,

Remove this definition of the money function ...

def money(spending_money):
    return money

Then, within the trip_cost function, replace the call to the money function, which is money(spending_money), with spending_money. The line of code within that function would become ...

    return plane_ride_cost(city) + hotel_cost(days) + rental_car_cost(days) + spending_money

#3

Thanks for the reply. I was having the same challenge but it’s solved now


#4

2 posts were split to a new topic: Hey, You Never Know!


#5

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