# Why does the city get called first?

In the following code, I needed to put “return hotel_cost(b) + plane_ride_cost(a) + rental_car_cost(b)”

Why does it not work when I use "return hotel_cost(a) + plane_ride_cost(b) + rental_car_cost(a)? I don’t understand why it calls the city first. Thanks.

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:
print “You aren’t going there!”

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

def trip_cost(a, b):
return hotel_cost(b) + plane_ride_cost(a) + rental_car_cost(b)

well, normally you have the freedom to determine the order of function parameters, but in this lesson, to validate your code correctly, the function is called multiply times, the choice was made (by creator of course) to have city as first argument and days as second

Is that done on the back end? How can I tell what the creator intended? Thanks for the quick reply last time!

Yep.

what do you mean? The exercise simply validates by calling the function, and see if your function returns the correct total

Given this function calls happen behind the scene, your function parameters (a and b) must be set right to handle the validating function calls.

In future exercises, I don’t know how I can tell the order of the function parameters that the creator intended. Or is this trial and error?

Also, what does this mean: “the function is called multiply?”

just follow the instructions? It told you city should be the first parameter, and days the second. If you go on adventure, you might risk something like this happening in the future.

called multiply times, (i forgot times), multiply function calls (to see of for each function call the correct total is returned)