while-loops enter the last time after condition is filled?

John Machin sjmachin at lexicon.net
Sun Apr 6 02:12:55 CEST 2008

On Apr 6, 9:53 am, skanem... at yahoo.se wrote:
> it seems to me from my results that when i use a while-loop it will
> execute once after the condition is met.
> ie the conditions is met the code executes one time more and then
> quits.

The syntax is this:

    while condition:

Do you mean that it executes do_something() only once, but you expect
it to execute more that once?

Or should we interpret your seemingly inconsistent statement by
changing "condition(s) is met" to "condition(s) is NOT met" -- in
other words, it is executing one EXTRA time after you expect it to
have stopped?

Perhaps you should supply a short example of runnable code (including
print statements to show what is happening), the actual output that
you got when you ran that code, and what was the output that you

More information about the Python-list mailing list