Re: [Tutor] pattern searching
by Ajith Gopinath other posts by this author
Nov 7 2009 12:15AM messages near this date
Re: [Tutor] pattern searching
|
Re: [Tutor] pattern searching
Thanks folks.
|| a j i t ||
On Sat, Nov 7, 2009 at 7:49 AM, bob gailer <bgailer@[...].com> wrote:
> Shashwat Anand wrote:
>
> > @Bob: the solution seems promising, and it's fast. Thanks for the
> > improvement. However I would like to do a minor change to the code to
> > prevent it going to infinite loop.
> >
> > import string
> >
> > text = raw_input()
> > translationTable = string.maketrans(string.ascii_uppercase +
> > string.ascii_lowercase, 'u'*26 + 'l'*26)
> > translatedText = text.translate(translationTable)
> > start = 0
> > while True:
> > start = translatedText.find('lul', start)
> > if start >= 0:
> > print text[start:start+3]
> > start += 1
> > else:
> > break
> >
> > Good catch. My bad!
>
>
> --
> Bob Gailer
> Chapel Hill NC
> 919-636-4239
> _______________________________________________
> Tutor maillist - Tutor@[...].org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
Thread:
Ajith Gopinath
Bob Gailer
Shashwat Anand
Bob Gailer
Ajith Gopinath
Lie Ryan
Bob Gailer
Modulok
Shashwat Anand
|