5 Oct 2011 5 Oct '11
On Wed, 2011-10-05 at 11:07 -0700, Ethan Furman wrote:
Ron Adam wrote:
On Wed, 2011-10-05 at 07:31 -0700, Ethan Furman wrote:
for i in finding(x, s): ... else: # unless for loop has a break, this will happen... # not a problem until you want more than just the first # occurrence of s in x
for i in finding(x, s): if i > 25: break <build or get a result> else: return result raise(ValueError("string 's' had an 'x' after position 25")
And how did you decide on the magical number 25?
I knew I should have used 42. ;-)