1

'''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?")
2
  • 2
    You need to fix the indentation and put a colon at the end of each while line, then it will work Commented Feb 12, 2017 at 4:15
  • careful, this may freeze your GUI... Commented Jun 30, 2021 at 7:25

1 Answer 1

1

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?")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.