"David Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Why does code snippet one work correctly, but not two. The only > difference is the placement of the "else". I know that indentation > affects execution, but how does it change behavior in the following > examples? Thank you. > > [snipped]
In the second example, "else" corresponds to "if", while in the first one it corresponds to "for". The tutorial example on "for ... else" loops (http://docs.python.org/tut/node6.html#SECTION006400000000000000000) uses the prime number computation you posted, so read it again if it's not clear what the "else" clause does with loops. George -- http://mail.python.org/mailman/listinfo/python-list