Why can i pass the quest just for changing the position of the argument?


#1





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

===
above I get the error message:
trip_cost('Charlotte', 2) raised an error: unsupported operand type(s) for -=: 'str' and 'int'
,
but when i change the def trip_cost(days,city) into def trip_cost(city,days)
,i pass the quest
i want to know the reason.


#2

unnamed parameters (which you have) have to be in the right order/sequence. How else does the function call now which arguments belong to which parameter?


#3

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