私は私の割り当てを行うにしようとしてきたが、私はこの出力を得ることは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()
とIMを用いた論理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'を呼び出します - あなたは全くループしていないので、ループの*最初の反復で' main'を再起動するだけです(再帰の深さが足りなくなります)遅かれ早かれ)。 –