Newbie question: Explain this behavior - a followup

David Smith ac063 at lafn.org
Fri Jul 15 16:20:46 EDT 2005


First, thanks to those who offered answers.  They didn't really answer
my question, only because I had not worked through the example
sufficiently well.  Doing this, I believe I understand what is
happening, and, if my understanding is correct, have discovered that for
other beginning and ending values for the two range statements, the
example doesn't work.

Given that the beginning and ending values for the inner range statement
are the same, the inner range statement will never be executed for its
first iternation; the else will be.  This is not correct.  Simply make
the beginning value a non-prime number, and the program still prints out
that that number is prime.  Changing both beginning and ending values on
the two statements, the ouput is differentially buggy.





More information about the Python-list mailing list