[英]Python: Multiple While Loops inside a While Loop
'''Hello, I'm trying to figure out why my second while loop, within a while loop is not executing in Python.''' '''你好,我想弄清楚为什么我的第二个 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?")
First, doing while x == True
is redundant, you can just do while x
, and second you are missing the colon at the end of the while statements.首先,执行while x == True
是多余的,您可以只执行while x
,其次您缺少 while 语句末尾的冒号。 Also you must respect the indentation in python.此外,您必须尊重 python 中的缩进。 Try this:尝试这个:
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.