在python程序中获取参数顺序混乱的错误

时间:2015-04-01 10:28:10

标签: python

当我运行以下代码时,获取错误如下:

 trip_cost should take exactly three parameters: city, days, and spending_money (in that order).

以下代码与所述的参数顺序相同。但是,即使它将旅行费用返还为1995年,仍然会得到同样的错误。

def plane_ride_cost(city):
    if city == "Charlotte":
       return 183
    elif city == "Tampa":
        return 220

    elif city == "Pittsburgh":
        return 222
    elif city == "LosAngeles":
        return 475

def rental_car_cost(days):
    cost = 40 
    if days >= 7:
        return (cost * days - 50)
    elif days >= 3 < 7:
        return (cost * days - 20)
    elif days < 3:
        return (cost * days)

def hotel_cost(nights):
    return 140 * nights

def money(spending_money):
    return spending_money

def trip_cost(city,days,spending_money):

    total_trip_cost = plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + money(spending_money)
    return total_trip_cost

print trip_cost("LosAngeles",5,600)

0 个答案:

没有答案