breaking out of nested loop

rbt rbt at athop1.ath.vt.edu
Tue Jul 12 10:19:04 EDT 2005


What is the appropriate way to break out of this while loop if the for
loop finds a match?

while 1:
    for x in xrange(len(group)):
        try:        
            mix = random.sample(group, x)
            make_string = ''.join(mix)
            n = md5.new(make_string)
            match = n.hexdigest()
            if match == target:
                print "Collision!!!"
                print make_string
		Stop = time.strftime("%H:%M:%S-%m-%d-%y", time.localtime())
		print "Stop", Stop
                break
            else:
                continue
        except Exception, e:
            print e     



More information about the Python-list mailing list