5/7 "Pulling it together" Help


Hi! Regarding exercise 5/7 "Pulling it together"

I was hoping somebody could explain why this works. :slight_smile:

def hotel_cost(nights):
  return 140 * nights
def trip_cost(city, days):
	return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)

With regards to using the argument (days) within the function hotel_cost(nights).
I don’t understand why this works and does not break the hotel_cost(nights) function.

Within the function, 140 is multiplied by the nights argument.

If the nights argument is changed to days , isn’t the function now broken since the value that 140 should be multiplied by, isn’t defined?

Thanks a lot!



what is days inside trip_cost function? isn’t the value what you passed for trip_cost function?

suppose you passed 5 as an argument for days.so now days=5.it’s working like

return hotel_cost(5)

so simply nights=5.

so nights argument is not changed to days.It holds the days as value. so

nights=5 # because days=5

I hope you’ve understand now :slight_smile:


Thank you for the response! I believe I get it now.


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