Search String for Word
digitalorganics at gmail.com
digitalorganics at gmail.com
Mon Jun 26 11:24:54 EDT 2006
And what if I want to search for an item in a tuple, is there a
similarly easy method?
Tim Chase wrote:
> > What's the best way to search a string for a particular word and get a
> > booleen value indicating whether it exists in the string or not?
>
> >>> substring = 'foo'
> >>> targetstring = 'blah foo bar'
> >>> substring in targetstring
> True
> >>> if substring in targetstring: print 'yup'
> yup
>
> http://docs.python.org/lib/typesseq.html
>
> -tkc
More information about the Python-list
mailing list