Syntax of 'in' : searching a list for a string

Dang Griffith noemail at noemail4u.com
Mon Mar 22 07:36:30 EST 2004


On 22 Mar 2004 02:02:51 -0800, robichon at esrf.fr (MarieR) wrote:

>Hi,
>
>Sorry for my newbie question:
>
>I want to check whether the string 'Remove' is present in a list 'supportList',
>but if I do 
>
>if ('Remove') in supportList: 
>
>or 
>
>if 'Remove' in supportList:
>
>I get the error message
>
>'in ' requires character as left operand.
>
>Thanks in advance for your help,
>
>Marie
What perfect timing--the question right before yours asked which
version of Python added support for that syntax.  You need to be using
2.3 or newer to use the 'in' operator to search for a string in a
string.
    --dang



More information about the Python-list mailing list