7. Plan Your Trip!


#1

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:

1815
None


#2

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


#3

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

My bad!


#4

All good now? No more questions?


#5

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

Ty!!


#6