Adam
Adam

Reputation: 141

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?")

Upvotes: 1

Views: 10575

Answers (1)

Seba
Seba

Reputation: 612

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?")

Upvotes: 1

Related Questions