2017-06-16 45 views
-2

任何人都可以理解爲什麼這不會重置,如果回答不正確?我有麻煩讓這個循環工作任何人都可以幫助我嗎?

def loop1: 
(print) ("Please Enter Your Name.") 
myName = input(:) 
(print) ("Hello " +myName) 
(print) ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C") 
hacthStatus = input() 
if hacthStatus == ('C'): 
    loop1() 
+0

請詳細說明您的問題聲明與預期的行爲解釋。 –

回答

1

你的代碼有沒有縮進,你也沒有定義功能正常

試試這個

def loop1(): 
     print ("Please Enter Your Name.") 
     myName = input(":") 
     print ("Hello " +myName) 
     print ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C") 
     hacthStatus = input() 
     if hacthStatus == 'C': 
      loop1() 

loop1() 

上面的代碼就相當於

hacthStatus = 'C' 
while hacthStatus == 'C': 
     print ("Please Enter Your Name.") 
     myName = input(":") 
     print ("Hello " +myName) 
     hacthStatus = input ("Would You Kindly Confirm If the Hatch Is Open Or Closed O/C\n") 
+0

,只是使一個永無止境的即時循環 –

+0

如果您鍵入除'C'之外的值,否則它會無限,只要您將'hacthStatus'值設爲'C',您的問題陳述不明確 –

+0

第二個i啓動它只是重新啓動 –

相關問題