7. Plan Your Trip!


this is what the exercise tell me to do:

After your previous code, print out the trip_cost( to “Los Angeles” for 5 days with an extra 600 dollars of spending money.

Don’t forget the closing ) after passing in the 3 previous values!

So, my code looks like:

def trip_cost(city, days, spending_money) :
  rental = rental_car_cost(days)
  hotel = hotel_cost(days -1)
  plane = plane_ride_cost(city)
  print rental + hotel + plane + spending_money

print trip_cost("Los Angeles", 5, 600)

But the answer is:

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)

I thought it was about the “-1” in “days” for the hotel_cost, but there weren’t any instructions to remove it. I tried removing it but it didn’t work either.

Why my code doesn’t work, isn’t like… the same?

Btw, after the execution of my code, there is no error, I couldn’t advance but not error was notified either, the only weird thing about it was two values being printed:



Your function only printed the total trip cost, you need to return it


Ty for pointing that out. I tried with “return” before but also called the function without the print statement.

My bad!


All good now? No more questions?


Not for now, I’m good to go with the next exercises.