How to jump out of nested 'for'-loops?

Sean DiZazzo half.italian at gmail.com
Tue Sep 29 05:32:14 CEST 2009


On Sep 28, 8:09 pm, Peng Yu <pengyu... at gmail.com> wrote:
> Hi,
>
> I want some command to jump out of nested loop. I'm wondering what is
> the most convenient way to do so in python.
>
> for i in range(10):
>   print "i = ", i
>   for j in range(10):
>     if i*10 + j == 50:
>       print i*10 + j
>       break # I want to jump out of the loops.
>
> Regards,
> Peng

Can you please give the people who answered your question a simple
"thank you"??

~Sean



More information about the Python-list mailing list