while loops code below while < print(ii= + print'bye'the variable gets set to to start nextthe program tests the condition on the while loop because is which is less than the code indented under the while statement will get executed this code prints the current value of and then executes the statement = + which adds to the variable is now and the program loops back to the while statement it checks to see if is less than and since is which is less than the indented code should be executed again so we print againadd to itand then loop back to check the while loop condition again we keep doing this until finally gets to at this pointthe while condition will finally not be true anymore and the program jumps down to the first statement after the whilewhich prints byethe end result of the program is the numbers followed by the messagebye infinite loops when working with while loopssooner or later you will accidentally send python into neverending loop here is an examplei= while < print(iin this programthe value of never changes and so the condition < is always true python will continuously print zeroes to stop program caught in never-ending loopuse restart shell under the shell menu you can use this to stop python program before it is finished executing sometimes never-ending loop is what you want simple way to create one is shown belowwhile truestatements to be repeated go here the value true is called boolean value and is discussed further in section the break statement the break statement can be used to break out of for or while loop before the loop is finished