"we pass the value of days to the new function in the argument nights" but WHY?!?!?!?!?!?!




my code is perfectly fine. i just DON'T understand why you can use a NEW ARGUMENT for the SAME function?!?!?!?

the original argument for "hotel_cost" is "(nights)" but the program says it's otay to use the argument "(days)" instead.... but WHY?!?!?!

def hotel_cost(nights):
    return 140.0*nights
def plane_ride_cost(city):
    if city == "Charlotte":
        return 183
    elif city =='Tampa':
        return 220
    elif city =='Pittsburgh':
        return 222.0
    elif city =='Los Angeles':
        return 475
def rental_car_cost(days):
    cost = 40*days
    if days>=7:
        cost -=50
    elif days>=3:
    return cost
def trip_cost(city, days):
   return rental_car_cost(days)+hotel_cost(days)+plane_ride_cost(city)


because argument name can be anything,the value is real.
when you call the function you have to pass real value in it.like

rental_car_cost(days) //here you called the rental_car_cost  function

so for example if days is 5, it would be rental_car_cost(5) so it'll pass 5 as real value.like

def hotel_cost(5):
    return 140.0*5

function is not checking what the name is,it just takes real value.

hope you've understand :slight_smile:


yes! this has helped, thank you!!


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