Finding the number of matching letters in two different string at the same indices
<p>I am having trouble finish python code.</p>

<p>overlap('','hello') → 0.</p>

<p>I have managed to get the number back when the length of the strings match but if one of the strings has a smaller length than the other. I keep getting index out of range. Can someone help me finish this.</p>

<pre><code>def overlap(string1,string2):
    count = 0
    for i in range(len(string1)):
        for j in range(len(string2)):
            if string1[i] == string2[j]:
                count = count + 1
                i+=1
            else:
                i+=1
        return count
</code></pre>

<p>When running this with a function call. if both strings are equal it gives me the correct number, but if one is smaller or longer then its index out of range. 
Thanks</p>