isPrime works but UnBoundLocalError when mapping on list
Terry Reedy
tjreedy at udel.edu
Tue Jul 15 17:00:48 EDT 2008
Andreas Tawn wrote:
> I think a better explanation is that in your original function, x only
> existed while the for loop was running. As soon as execution hit the
> break statement, x ceased to exist.
Wrong. For loop variables continue after the loop exits. This is
intentional. Mensanator gave the correct explanation (loop never enters
for nbr==1).
More information about the Python-list
mailing list