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

Bjoern Paschen paschen at mavd.de
Mon Mar 22 11:26:41 CET 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