FAQ: Taking a Vacation - Pull it Together

This community-built FAQ covers the "Pull it Together " exercise from the lesson “Taking a Vacation”.

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

Learn Python

FAQs on the exercise _Pull it Together _

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 (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.

Ask or answer a question about this exercise by clicking reply (reply) below!

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

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

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!

Hi all,

I’m about to do this exercise but I just have a couple of issues with the example: Why are the parameters (arguments) different for the third to the first and second? And what does 'returns the sum of the previous two functions when called with a and b, respectively.

Many thanks
Josh

1 Like

Whenever I press run, an error message pops up saying “trip_cost(‘Charlotte’, 3) returned ‘563’ instead of the correct value 563” or different values. It always says it returns x instead of x, and even though it’s always correct, it never says it is. What did I do wrong?

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):
  if days >= 7:
    return 40 * days - 50
  elif days >= 3:
    return 40 * days - 20
  else:
    return 40 * days
  
def trip_cost(city, days):
  return str(rental_car_cost(days) + hotel_cost(days - 1) + plane_ride_cost(city))

There is no spending_money value in your code.

This worked for me:

#hotel cost function
def hotel_cost(nights):
  #cost is fixed at $140
  return 140 * nights

#plane cost function
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 "There are no flights from that city."

#rental car cost funciton
def rental_car_cost(days):
  cost = 40 * days
  if days >= 7:
    cost += - 50
  elif (days >= 3) and (days < 7):
    cost += - 20
  return cost

#put it all together
def trip_cost(city, days):
  return hotel_cost(days - 1) + plane_ride_cost(city) + rental_car_cost(days)