Done 5/7, but dont understand


I wrote the code below and it 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
def rental_car_cost(days):
cost = 40 * days
if days >= 7:
cost -= 50
elif days >= 3:
cost -= 20
return cost
def trip_cost(city,days):
return hotel_cost(days) + plane_ride_cost(city) + rental_car_cost(days)

Obviously when all the indents are in place it works. I dont understand why I dont have to call nights though. Why do I call days instead of nights for hotel_cost?


Because I think days and nights are just the same according to them.
for example if u plan you trip for 5 days then night=5.
It's what i understood.


Thank you for your answer. I thought city,days,nights were sort of like variables though? I know they are arguments but I thought they worked similarly. Do you know how it knows that days and nights are the same? :smile:


Calling the functions hotel_cost, plane_ride_cost and rental_car_cost in trip_cost simply inserts the values given for city and days when trip_cost is called. It has nothing to do with the words.
Caling trip_cost("Tampa", 6) would return hotel_cost(6) + plane_ride_cost("Tampa") + rental_car_cost(6)