나는 코드 아카데미 운동의 휴가 비용에 대한 모델을 만들고있어, 나는 세 가지 기능 지금까지 정의, 인수 nights
에 인수 days
, hotel_cost
와 rental_car_costs
및 plane_ride_cost
촬영 city
. 코드는 다음과 같습니다최대 재귀 깊이 초과 : 코드 아카데미; 방학의 인수 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)
처럼이 일 밤의 값을 전달하고, 단지의 경우 어쨌든에서 밤을 대체하려고했습니다,하지만 난 여전히 똑같은 오류 메시지가 보인다. 내가 뭘 잘못하고 있고, 최대 심도 재귀는 평균을 초과합니까?
에 오신 것을 환영합니다. 귀하의 질문에 세부 사항이 부족합니다. 읽기 : http://stackoverflow.com/help/how-to-ask – Shubham
나는 "return hotel_cost (days)"을 없앴습니다. 이것은 문제로 언급되었지만 지금은 "plane_ride_cost ('Charlotte ')는 최대 재귀 깊이를 초과했습니다. "return plane_ride_cost (city)를 빼내고 함수의 나머지 부분에 넣으려고했지만, 그렇게했을 때 tampa는 적절한 값 대신에 183을 반환한다고합니다. – Nertfertsatwork