On Thu, 13 Nov 2008 02:16:32 -0800, Chris Rebert wrote: > On Thu, Nov 13, 2008 at 2:07 AM, TP <[EMAIL PROTECTED]> > wrote: >> >> In the following example, is this possible to affect the two iterators >> to escape the two loops once one "j" has been printed: >> > Non-exception alternative: > > done = False > for i in range(5): > for j in range(i): > print j > done = True > break > if done: > break
Another alternative is explicitly jumping in the outer loop:: for i in range(5): # use xrange for larger ranges for j in range(i): print j break else: continue # applies already to the outer loop break HTH, -- Robert "Stargaming" Lehmann -- http://mail.python.org/mailman/listinfo/python-list