简体   繁体   中英

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.'''

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. Also you must respect the indentation in python. Try this:

x = True
y = False
z = True

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM