我在代码学院的练习中为假期费用制定了一个模型,并且我有至今定义的三个函数rental_car_costs
,参数days
,hotel_cost
,参数nights
和plane_ride_cost
的参数为city
。代码如下所示:超过最大递归深度:Code Academy;休假5/7
def hotel_cost(nights):
return hotel_cost(nights)
return 140 * nights
def plane_ride_cost(city):
return plane_ride_cost(city)
if "Charlotte":
return 183
elif "Tampa":
return 220
elif "Pittsburgh":
return 222
elif "Los Angeles":
return 475
def rental_car_cost(days):
rental_car_cost = 40 * days
if days >= 7:
rental_car_cost -= 50
elif days >= 3:
rental_car_cost -= 20
return rental_car_cost
所有的作品,我都没有问题,但我想创建一个名为trip_cost
功能,我不断收到超过最大递归深度。该代码看起来像这样
def trip_cost(city, days):
return plane_ride_cost(city) + hotel_costs(days) + rental_car_cost(days)
我晚上的值传递给天,以防万一我试着反正代的夜晚,但我仍然得到完全相同的错误消息。我做错了什么,最大深度递归超过了什么意思?
欢迎使用stackoverflow。你的问题缺乏细节。阅读此:http://stackoverflow.com/help/how-to-ask – Shubham
我拿走了“返回hotel_cost(天)”,这是所谓的问题,但现在它说“plane_ride_cost('夏洛特')提出了一个错误:超过最大递归深度“我试图带走”返回plane_ride_cost(城市),并将其放在函数的其余部分之下,但是当我这样做时,它说坦帕返回183,而不是它的正确值220. – Nertfertsatwork