On Fri, 04 Aug 2006 14:55:34 -0700
John Machin <[EMAIL PROTECTED]> wrote:

#> > def test(data):
#> >     format, index = 'abcd', 0
#> >     for c in data:
#> >         i = format.index(c)
#> >         if i > index+1:
#> >             return False
#> >         index = i
#> >     return index==format.index('d')
#> >
#> > Could be made faster if format was made a dictionary or if one wanted
#> > to compare characters directly. Writing (and profiling) left as an
#> > exercise for a reader.
#> 
#> Premature optimisation ....
#> 
#> #>>> test('bcd')
#> True
#> #>>>

Oooops... You are right. Should be 
    format, index = 'abcd', -1
of course. Thanks.

-- 
 Best wishes,
   Slawomir Nowaczyk
     ( [EMAIL PROTECTED] )

I believe that math illiteracy affects 7 out of every 5 people.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to