Help please!


Why is my code unaccepted when I change the order of the arguments (days, city) in the trip_cost function yet i get no error message.

 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
        return 475

def rental_car_cost (days):
    cost = days * 40
    if days >= 7 :
        cost -= 50
    elif days >= 3:
        cost -= 20
    else :
        print "You cannot get both discounts!"
    return cost

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


Well if you do like I think you just suggested like this:

def trip_cost(days, city):

I get this error: Oops, try again. trip_cost('Charlotte', 6) raised an error: unsupported operand type(s) for -=: 'str' and 'int'. So if you are not getting an error than something else might be wrong because the above code is wrong (obvious by the error)


You won't pass because the lesson checks the function with the parameters in that order.
For example, the lesson correctness test will call the function, with set parameters, and expect a certain outcome, and when it doesn't get that outcome, you can't pass.


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