else clauses in while and for loops

Paul Jackson pj at sgi.com
Tue Apr 18 11:15:06 EDT 2000


Perhaps I need some more coffee, but I suspect that the
example in the previous message is indented wrong, and
should be:

        s = list_of_strings

        for i in range(len(s)):
            if s[i] == something:
                break
        else:
            print "didn't find anything"
            raise ValueError

        print "index is", i
-- 

=======================================================================
I won't rest till it's the best ...	   Software Production Engineer
Paul Jackson (pj at sgi.com; pj at usa.net) 3x1373 http://sam.engr.sgi.com/pj



More information about the Python-list mailing list