编译错误后:不能调用功能正常的蟒蛇由于未知的原因
Traceback (most recent call last):
File "python", line 29, in <module>
File "python", line 26, in trip_cost
TypeError: 'int' object is not callable
以下是我写的开支计算应用程序的代码。最后在trip_cost函数内传递四个参数,但在函数定义中定义了四个参数。
def hotel_cost(nights):
return 140 * nights
def spending_money(money):
return money
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 trip_cost(city,days,spending_money):
total_trip_cost = plane_ride_cost(city) + rental_car_cost(days) + hotel_cost(days) + spending_money(spending_money)
return total_trip_cost
print trip_cost("LosAngeles",5,600)
然后它说:trip_cost应该采取三个参数:city,days和spend_money(按该顺序)。其已经以相同的顺序排列。 – kashminder 2015-04-01 09:36:28
你有什么改变? – TZHX 2015-04-01 09:39:46
我已将函数名称spend_money更改为money并将其更改为spend_money。获得1995年旅行成本与上述错误。 – kashminder 2015-04-01 09:44:50