Break the nested(double) loop in python

Posted by prosseek on Stack Overflow See other posts from Stack Overflow or by prosseek
Published on 2010-04-08T02:06:55Z Indexed on 2010/04/08 2:13 UTC
Read the original article Hit count: 306

Filed under:
|

I use the following method to break the double loop in Python.

for word1 in buf1: 
    find = False 
    for word2 in buf2: 
        ... 
        if res == res1: 
            print "BINGO " + word1 + ":" + word2 
            find = True 
    if find: 
        break 

Is there better way to break the double loop?

© Stack Overflow or respective owner

Related posts about python

Related posts about nested-loops