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

Garry Knight garryknight at
Mon Mar 22 22:11:58 CET 2004

In message <6d6b80e0.0403220202.356f62fc at>, 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.

If supportList is a list of strings, then this should work in Python 2.3 and

for i in supportList:
  if 'Remove' in i:
    print 'Found it in', i

Garry Knight
garryknight at  ICQ 126351135
Linux registered user 182025

More information about the Python-list mailing list