2017-04-02 4 views
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 
+0

なぜ2つの 'while 'ループがお互いの中にあるのですか? –

+0

あなたは** ** ** whileループを持っています。外側のものを外して、本体を外します。 –

+0

今すぐお仕事、ありがとうございます.... – marte

答えて

0

。外側のものを外すとうまくいく。 また、内側にひっかかることもありませんwhileループ