First page Back Continue Last page Overview Graphics

The else Branch with Break

Normally, the while loop finishes, if the condition is not fulfilled anymore.

Additionally while loop can

be exited by the

unconditional break statement.

The else branch of the while construct will not be executed, if the while is left via break.

while condition:

statement1

...

statementn

else:

statement1

...

statementn

False

condition

True

statement1

...

if ...

break

...

continue

...

statementn

else:

statement1

statement2

...

statementn

Further

statements

of program