0
こんにちは私はこの単純なプログラムを作ったが、問題がある。すべてのプログラムはうまくいきますが、最終的な質問に「私は別の操作をしますか?はい、いいえ」と答えると、最後に入力のウィンドウが閉じないようにします。 (これはおそらく私がwhileループを適切に閉じていないことを意味します)。私は間違いなく正しく閉じることができますか?Python close a while
CODE:while
ループにあなたが持っている
def multiplication(b, c):
a=b*c
return a
def division(b, c):
a=b/c
return a
def main():
Menu = input("""Choose one operation :
1.Multiplication
2.Division
-------------------->""")
if Menu=="1":
b=float(input("Insert a number"))
c=float(input("Insert a number"))
print("Result :",multiplication(b, c))
elif Menu=="2":
b=float(input("Insert a number"))
c=float(input("Insert a number"))
print("Result :",division(b, c))
main()
while True:
while True:
cont=input("Do you want to make another operation? yes or no")
if cont=="yes":
main()
else:
print ("Close")
break
なぜ2つの 'while 'ループがお互いの中にあるのですか? –
あなたは** ** ** whileループを持っています。外側のものを外して、本体を外します。 –
今すぐお仕事、ありがとうございます.... – marte