Which code is better to find the first recurring alphabet in a string? : <p>The first code is:</p>

<pre><code> string = "DBCABA"
 #computing the first recurring alphabet
 def compute_reccuring():
     for a in string:
         var = string.count(a)
         if var &gt; 1:
            final = str(a) 
        print(str(final) + " is repeated first")
        break
</code></pre>

<p>The second code is:</p>

<pre><code>def recurring():
    counts = {}
    for a in string:
        if a in counts:
           print(a)
        else:
           counts[a] = 1
</code></pre>

<p>Both of these codes work but I don't know which one is better in performance.</p>
