On Sun, Sep 16, 2012 at 8:33 PM, eryksun <eryk...@gmail.com> wrote:
>
> The 'in' operator also searches for a substring:
>
>     >>> '' in 'abc'
>     True

I forgot to mention, this use of slices is a peculiarity to strings.
In contrast, list.index and list.__contains__ ("in") match against
individual items. An empty list slice [] is not "in" ['a', 'b', 'c'].
Be careful about this use of substrings:

    >>> 'care' in 'careful programming'
    True
    >>> 'care' in 'careful programming'.split()
    False
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to