How to ignore lower as well upper case of a word in python?
<p>I want to find <strong>Andy</strong> in the list. Either <strong>Andy</strong> comes in upper or lower case in string the program should return <code>True</code> </p>

<pre><code>String1 ='Andy is an awesome bowler' 
String2 ='andy is an awesome bowler'
String3 ='ANDY is an awesome bowler'
</code></pre>

<p>I am doing in this way</p>

<pre><code>if 'Andy' in String1:
   print ('success')
else:
    print("Nothing")
</code></pre>

<p>But it is working only for <code>Andy</code> not for <code>andy</code> or <code>ANDY</code>. I do not want to use <code>Pattern</code> matching.  By using <code>lower()</code> the <code>Andy</code> can be converted to lower case but I need both at a time ignoring lower as well as upper case. Is it possible? </p>

<p>If you are sure that you string contains only ascii characters, use the following approach: </p>

<pre><code>if 'andy' in string1.lower():
    do something
</code></pre>

<p>If your comparision strings involve unicodedata: </p>

<pre><code>import unicodedata

def normalize_caseless(text):
    return unicodedata.normalize("any_string", text.casefold())

def caseless_equal(left, right):
    return normalize_caseless(left) == normalize_caseless(right)
</code></pre>

python