[英]Python: Multiple While Loops inside a While Loop
'''你好,我想弄清楚為什么我的第二個 while 循環,在一個 while 循環中沒有在 Python 中執行。'''
x = True
y = False
z = True
while x == True
while y == True
print("Won't print")
while z == True
print("Should print, right?")
首先,執行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?")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.