Is there any way to say ignore case with "in"?

Fredrik Lundh fredrik at
Fri Apr 4 23:06:32 CEST 2008

tinnews at wrote:

> Is there any way in python to say
>     if string1 in string2:
>         <do something>
> ignoring the case of string1 and string2? 

     if string1.lower() in string2.lower():

(there's no case-insensitive version of the "in" operator in stock Python)


More information about the Python-list mailing list