title: Posssible to go back in a for-loop after it's done?
body: <p>I'm trying to make an anagram program and my program is semi working. Sometimes it gives me the strings that I want which are the first and the last two strings. But sometimes it doesn't print anything.</p>
  <p>I thought I could fix that problem by putting the second <code>for</code> loop inside a function so that if the last <code>if</code> statements don't get called, I could run the whole second loop again. But when I do that, it prints a bunch of stuff and then the program reaches the print limit and crashes. I then tried the put the second for loop inside a <code>while</code> loop but when I do that the program doesn't even run.</p>
  <pre><code>text = &quot;texxtttt&quot;
  text_list = [&quot;tettxtxt&quot;, &quot;ttexxtte&quot;, &quot;texxtexxxt&quot;, &quot;tttttxxe&quot;, &quot;txextttt&quot;]
  
  input_unique_letters = &quot;&quot;.join(set(text))
  
  for i in range(len(input_unique_letters)):
      input_letter = input_unique_letters[i:i+1]
      input_letter_n = text.count(input_letter)
  
  for i in range(len(text_list)):
      list_unique_letters = &quot;&quot;.join(set(text_list[i]))
  
      list_word = text_list[i]
      list_letter = list_word[i:i+1]
      list_letter_n = list_word.count(list_letter)
  
      if len(text) == len(list_word):
          if input_letter == list_letter and input_letter_n == list_letter_n:
              print(list_word)
  </code></pre>
  <p>Heres the code that reaches the printing limit:</p>
  <pre><code>text = &quot;texxtttt&quot;
  text_list = [&quot;tettxtxt&quot;, &quot;ttexxtte&quot;, &quot;texxtexxxt&quot;, &quot;tttttxxe&quot;, &quot;txextttt&quot;]
  
  input_unique_letters = &quot;&quot;.join(set(text))
  
  for i in range(len(input_unique_letters)):
      input_letter = input_unique_letters[i:i+1]
      input_letter_n = text.count(input_letter)
  
  def coroutine():
      for i in range(len(text_list)):
          list_unique_letters = &quot;&quot;.join(set(text_list[i]))
  
          list_word = text_list[i]
          list_letter = list_word[i:i+1]
          list_letter_n = list_word.count(list_letter)
  
          if len(text) == len(list_word):
              if input_letter == list_letter and input_letter_n == list_letter_n:
                  print(list_word)
  
          else:
              coroutine()
  
  coroutine()
  </code></pre>