我一直试图做我的任务,但我碰到的使用Python 3获取的功能相同的范围值
print("Car Service Cost")
def main():
loan=int(input("What is your loan cost?:\t"))
maintenance=int(input("What is your maintenance cost?:\t"))
total= loan + maintenance
for rank in range(1,10000000):
print("Total cost of Customer #",rank, "is:\t", total)
checker()
def checker():
choice=input("Do you want to proceed with the next customer?(Y/N):\t")
if choice not in ["y","Y","n","N"]:
print("Invalid Choice!")
else:
main()
main()
并即时得到这个输出逻辑error.I'm:
Car Service Cost
What is your loan cost?: 45
What is your maintenance cost?: 50
Total cost of Customer # 1 is: 95
Do you want to proceed with the next customer?(Y/N): y
What is your loan cost?: 70
What is your maintenance cost?: 12
Total cost of Customer # 1 is: 82
Do you want to proceed with the next customer?(Y/N): y
What is your loan cost?: 45
What is your maintenance cost?: 74
Total cost of Customer # 1 is: 119
Do you want to proceed with the next customer?(Y/N): here
我每次都有我的排名为1。我究竟做错了什么?
'main'调用'checker'进入循环,调用'main' - >你根本没有循环,只需在循环的每次* first *迭代中重新启动'main'(并且你将用完递归深度迟早)。 –