# FAQ: Taking a Vacation - Hey, You Never Know!

This community-built FAQ covers the “Hey, You Never Know!” exercise from the lesson “Taking a Vacation”.

Paths and Courses
This exercise can be found in the following Codecademy content:

## FAQs on the exercise Hey, You Never Know!

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

## Join the Discussion. Help a fellow learner on their journey.

Agree with a comment or answer? Like () to up-vote the contribution!

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

The code below is what I inputted for the solution to this module and it kept getting the error message: “trip_cost(‘Tampa’, 5, 0) returned 1100 instead of the correct value 960”

``````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) + plane_ride_cost(city) + spending_money
``````

However, when checking the solution, it displays this as the answer:

``````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) + plane_ride_cost(city) + spending_money
``````

Can someone clear this up for me?

1 Like

Same problem. I copied the solution you posted and paste it in the editor. It still thinks the code is wrong and i’m only able to progress when viewing the solution…

then please post your code here, then we can analyze if something is wrong with your code, or determine if there might be a bug in the exercise validation (small change, but not impossible)

5*140 = 700
Tampa = 220
(5*40) -20 = 180

700 + 200 + 180 = 1100

So neither of the answers are correct.

960 is 140 less than 1100, which makes sense because you are only charged for the nights you stay at a hotel. (Mornings are full of sad, tired, hungover people trying not to look each other in the eye).

I’m pretty sure, the argument for hotels should be (days-1).

Less a coding error more of human error.

Hope that helps!

Cheers!

When writing the code I put an additional conditional on the night stays and rental costs. The conditional was such that if days are 0 you do not get charged for the hotel or rental. The code errors out on the function of 0 days such that you would be given -\$140 for staying -1 days at the hotel. I believe the codeacademy evaluating function has a bug.

“trip_cost(‘Tampa’, 0) returned 220 instead of the correct value 80”

In reality this should be either \$0 for the cost or \$220 depending on how you see it. If days are 0 then you either didnt fly or you flew there and didnt stay or drive around. You would not get a negative value from the hotel.

I typed the correct code and even then the compiler errors pop as have you declared the function ,after clicking the solution the same of what I typed was there .What is this behaviour codecademy?

The sample below works.

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**
** else: **
** return “Forum is hint”**

def rental_car_cost(days):
** costs = 40 * days **
** if days >= 7:**
** costs -= 50**
** elif days >= 3 and days < 7:**
** costs -= 20**
** return costs**

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

print(trip_cost(‘Los Angeles’, 5, 5))
print(trip_cost(“Tampa”, 7, 7))
print(trip_cost(‘Charlotte’, 6, 3))
print(trip_cost(“Pittsburgh”, 8, 4))

@arcdb is correct you need to put

Why does the test code keep using zero days as an input? And why should the code take a zero days input to mean that the hotel pays you not to stay there? Not a very pretty code, IMO.

This program could use some refinements, sounds like a good challenge!

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

Can someone help me here. I don’t seem to know what is wrong with my code except that something went wrong.

Why is spending_money just tacked on in the trip_cost argument without ever being defined? If the code is run, how would it quantify “spending_money” without having an argument associated with it like “days” or “city”?

I am feeling this is a conflicting lesson

I completely agree with this statement. All lessons up until now have led me to believe arguments must be defined yet this is accepted? Unless I am missing something easy, I am confused as to why this code works.