2017-02-12 251 views
1

「」「你好,我想while循環,while循環內沒有在Python執行找出原因,我的第二個」「」Python:多在While循環

x = True 
y = False 
z = True 

    while x == True 

     while y == True 
      print("Won't print") 

     while z == True 
      print("Should print, right?") 
+2

您需要修復縮進並在每行的末尾放一個冒號,然後它將工作 –

回答

1

內循環首先,做while x == True是多餘的,你可以只做while x,其次你在while語句結尾缺少冒號。你也必須尊重Python中的縮進。試試這個:

x = True 
y = False 
z = True 

while x: 
    while y: 
     print("Won't print") 

    while z: 
     print("Should print, right?")