How to ignore capitalization BUT return same capitalization as input
<p>My code intends to identify the first non-repeating string characters, empty strings, repeating strings (i.e. <code>abba</code> or <code>aa</code>), but it's also meant to treat lower and upper case input as the same character while returning the accurate non-repeating character in it's orignial case input. </p>

<pre><code>def first_non_repeat(string):
    order = []
    counts = {}
    for x in string:
        if x in counts and x.islower() == True:
            counts[x] += 1
        else:
            counts[x] = 1 
            order.append(x)
    for x in order:
        if counts[x] == 1:
            return x
    return ''
</code></pre>

<p>My logic on line 5 was that if I make all letter inputs lowercase, then it would iterate through the string input and not distinguish by case. But as of now, take the input <code>'sTreSS'</code>and output  is <code>'s'</code> when really I need <code>'T'</code>. If the last two <code>S</code>'s were lowercase, then it would be <code>'T'</code> but I need code flexible enough to handle any case input. </p>

<p>Here's little change u can make to your code to make it work. </p>

<pre><code> def first_non_repeat(string):
            order = []
            counts = {}
            for x in string:

                char_to_look = x.lower()   #### convert to lowercase for all operations

                if char_to_look in counts :
                    counts[char_to_look] += 1

                else:
                    counts[char_to_look] = 1 
                    order.append(char_to_look)

           for x in string:   ### search in the string instead or order, character and order will remain the same, except the case. So again do x.lower() to search in count
                if counts[x.lower()] == 1:
                    return x
            return ''1
</code></pre>

python string case