find() a larger string within a smaller string

Mensanator mensanator at aol.com
Fri Nov 14 14:33:19 EST 2008


On Nov 14, 1:20 pm, korean_dave <davidrey... at gmail.com> wrote:
> stringa = "hi"
> stringb = "hiyoooo"
>
> I'd like it to return -1 when I do:
>
> returnVal = stringa.find(stringb);
>
> Instead, it treats stringa as "hi" and stringb as "hi".
>
> How do I solve this?

Try this:

>>> stringa = 'hi'
>>> stringb = 'hiyoo'
>>> stringa.find(stringb)
-1



More information about the Python-list mailing list