Checking a variable against a list and seeing if a word in that list starts with the variable
<p>I'm trying to write a function that uses a checker that could be any length and checks it against the list. It should be case insensitive when checking and print the word. Example below</p>

<p><code>Input= startsWith('a',['apple','ApPle','orange','Apple','kiwi','apricot'])</code></p>

<p><strong>Output:</strong></p>

<pre><code>apple
ApPle 
Apple 
apricot
</code></pre>

<p>But, it prints every string in the list all in lower case.</p>

<pre><code>def startsWith(checker,lister):

    checker.lower()
    size = len(lister)
    i=0
    checklength = len(checker)
    lister = [element.lower() for element in lister]
    while(i&lt;size):
        checkinlist = lister[i]
        if(checkinlist[0:checklength-1] in checker):
            # this is just to test to see if the variables are what i need
            # once the if statement works just append them to a new list
            # and print that
            print(lister[i])

        i=i+1
</code></pre>

<p>Here's the root of the problem</p>

<pre><code>lister = [element.lower() for element in lister]
</code></pre>

<p><code>lister</code> now only contains lowercase strings, which you then print. You need to delay the <code>lower()</code> until you check for <code>checker</code>. </p>

<hr>

<p>No need to check the length of anything. You can use <a href="http://stackoverflow.com/questions/12319025/filters-in-python#12319034"><code>filter</code></a></p>

<pre><code>def startsWith(checker, lister):
    return list(filter(lambda x: x.lower().startswith(checker.lower()), lister))

for x in startsWith('a',['apple','ApPle','orange','Apple','kiwi','apricot']):
    print(x)
</code></pre>

<p>Output</p>

<pre><code>apple
ApPle
Apple
apricot
</code></pre>

python