Hey, You Never Know!

#1

``````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):
cost = days * 40
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-1) +   plane_ride_cost(city) + spending_money
``````

I see that if I change

``````hotel_cost(days-1) for hotel_cost(days) it works

why??? if we are working with hotel_cost(days-1) why i have to change it?

``````

#2

It seems like you’re forgetting one part.

Modify what the trip_cost function does.
Add the variable spending_money to the sum that it returns.

#3

I dont get it, i have it.

check it

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

``````

#4

I reset and re-tried it and got the same error, not too sure why… but then moving on to the next step, I wrote days-1 again and it worked. Could be nothing more than a bug, I didn’t pay much attention to it going through the exercise, hence my confusion when I looked back at it.

Sorry, can’t be of any more help than that at the moment…

#5

I ran into the same issue. I reported it as a bug since the instructions stated to use hotel_cost(days - 1) however the solution uses hotel_cost(days)

#6

The test cases should be corrected to cater for the (days-1) argument

#7

Same issue here, I used the workaround mentioned above and reported a bug.

#8

Thank you Rubin. I thought I was crazy for a second

#9

Same issue here. I don’t know how to report a bug, but this should be fixed.

#10

^There’s a button on the bottom of the instructions where you can report the exercise for having a bug in it. I’ll do that.

#11

The third parameter “spending_money” in error messages is always 0. However, it seems the answer is being validated against some non zero value for spending_money.
I have reported this as a bug.

#12

Thank you. This is a definite bug.
If it was not for you, 30 minutes would have been three hours.

#13

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