title: find the first instance of a 2 character repeating segment in a string
body: <p>I am trying to find the first instance of a 2 character repeating segment in a string. so if the string is abcdabcd i would want it to return "ab". i think i need a nested while loop but cannot figure out what is wrong with how i am approaching. </p>
  
  <pre><code>i = 0
  j = (i+2)
  k = (i+1)
  m = (k+2)
  a = newstr[i:j]
  b = newstr[k:m]
  while i &lt; len(newstr)-2:
      while k &lt; len(newstr)-1:
          if a == b:
          print (a)
  
  i +=1
  </code></pre>
  
  <hr>
  
  <p>separately i tested out while loop with a very simple loop and even that isn't working- what am i doing wrong in both the above and the below? THANKS!!</p>
  
  <pre><code>i = 0
  j = i + 2
  a = newstr[i:j]
  while i &lt; len(newstr)-2:
      if a == "15":
          print (a)
  i +=1
  </code></pre>