title: Find a repeated character in a string (python)
body: <p>I managed to find this code online which showed me how to find and print a repeated character in a string.  I'm confused as to how it's working though.  I don't understand what the h[i] = 0 part is technically doing.  Can someone please explain?</p>
  
  <pre><code>a = 'abcdeab'
  
  h = {}
  
  for i in a:
      if i in h:
          print(i)
      else:
          h[i] = 0
  </code></pre>
  
  <p>I understand how it's iterating over the string, but I don't understand how it's being added to the dictionary in order to be checked if it already exists in that dictionary or not.  Setting h[i] = 0 is what's throwing me off.  I don't understand why it's being set to 0.</p>
  
  <p><strong>I'm adding this after the problem was answered:</strong>
  I ended up creating a different solution and thought I would post it in case anyone else was looking into the same problem.  It is as follows (using a list instead of a dictionary):</p>
  
  <pre><code>a = 'abcdeab'
  
  h = []
  for i in a:
      if i in h:
          print(i)
      else:
          h.append(i)
  </code></pre>
  
  <p>Also, if you're looking for ONLY the first occurrence of a repeated character, you would add <code>break</code> after <code>print(i)</code>.  In this case, it would only print <code>a</code> instead of both <code>a</code> and <code>b</code>.  </p>