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

Bjoern Paschen paschen at mavd.de
Mon Mar 22 05:26:41 EST 2004


MarieR wrote:

> 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.

for i in supportList:
    if i == 'Remove':
        doSomething()

I am sure there is a shorter way, but this will work.

Bjoern



More information about the Python-list mailing list