How does a=2 twice in this code sample? I am just starting out learning code.

The output of the following code is OOOXOXOO, but I don't see how X can be printed twice. How does a=2 more than once?

a = 1
while a &lt; 3:
    b = 1
    while b &lt; 3:
        if a == 2:
            print ("X"),
        print ("O"),
        b = b + 1
    print ("O"),
    a = a + 1
Think carefully about the flow.

Your innermost While loop runs through b = 1, 2, each time it hits.

It does this for EACH value of a in the outermost loop.

So when a == 2, we progress inward and run through that loop twice. a == 2 both times.