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>When comparing two letters, use lower() to compare the characters in a string. An example would be:</p>

<pre><code>string ="aabcC"
count = 0
while count &lt; len(string) - 1:
    if string[count].lower() == string[count + 1].lower():
        print "Characters " + string[count] + " and " + string[count + 1] + " are repeating."
    count += 1
</code></pre>

python string case