Python list integrateUpper/Lowercase check?
<p>I currently use following code to select rows from a dataframe:</p>

<pre><code>list = ['3d block','3D Block','3D block','3d Block','cafe','Cafe']
data[data['description'].str.contains('|'.join(list))]
</code></pre>

<p>As you can see, I currently implement different queries for upper/lowercase, as I realized that '3d print' didn't really match all the items in question.</p>

<p>Can the code above be improved or shortened, so that the list includes all possible variations of upper/lowercase characters, both for one and two words?</p>

<p>You can simply convert them all to lower using the <code>string.lower()</code> function</p>

<p>Make your list contain only lower case characters. But you can do a safe check for that too</p>

<pre><code>my_list=['3d block', 'cafe']

# As karthik suggested, just to be safe, convert your list to lowercase
for i in range(len(my_list)):
    my_list[i]=ele.lower()

my_query='3D bLoCk'
if my_query.lower() in my_list:
    print('yes')
</code></pre>

<p>prints <code>yes</code></p>

python list uppercase lowercase