searching strings

Chris Rebert clp2 at rebertia.com
Tue Mar 10 02:24:24 CET 2009


On Mon, Mar 9, 2009 at 6:18 PM, Daniel Dalton <d.dalton at iinet.net.au> wrote:
> Hi,
>
> I'm writing a program where I search a variable (path), and see if it
> contains the whole string of variable name
> so:
> if name in path:
>  ....
> else:
>  ....
>
> One question about this, how can I make it do exactly what it's doing
> now, except ignore case? eg. if I do this:
> i="A"
> j="ab"
> i in j
> should return true... How do I do this?

Normalize the case of the strings:

i.lower() in j.lower()

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list