title: Python gives a "Syntax Error" on "else:"
body: <p><strong>My Error</strong><br>
  Python throws a syntax error pointed at the last <em>"e"</em> of <em>"else:"</em>, preceded by an <em>if</em> statement and inside a <em>while</em> loop.<br>
  <strong>My Objective</strong><br>
  Test if certain parameters are true, if true then go to the beginning of the loop and if not true then perform certain statements and increment a value.<br>
  <strong>My Source Code</strong>  </p>
  
  <pre><code>from random import randint
  
  def returnDigRoot(num):
      digs = []
      while len(str(num)) != 1:
          num = str(num)
          for each in num:
              digs.append(each)
          num = int(num)
          digs = [int(i) for i in digs]
          num = sum(digs)
      return(num)
  def rnum():
      return(randint(1,99999))
  ran_nums = []
  sols = []
  it = 1
  </code></pre>
  
  <p>The problem area is here</p>
  
  <pre><code>while it &lt;= 3:
      print("Generating numbers")
      current = randint(1,99999)
      print("randomly intializing the 'current' int value")
      print("testing if the digital root is greater than 6")
      if returnDigRoot(current) &gt; 6:
          print("going back to start of loop")
          continue
      print("testing if it isnt")
      else:
          ran_nums.append(current)
          print("append 'current' to ran_nums")
          sols.append(returnDigRoot(current))
          print("appending its digital root to sols")
          it += 1
          print("incrementing the iterator variable")
  </code></pre>
  
  <p><strong>My Research</strong><br>
  I looked at many questions on StackOverflow and other sites and could not find a solution to my problem; most problems people had with <em>else</em> statements were related to tabbing errors, preceding errors (which I checked for), no preceding <em>if</em> statement, or multiple <em>else</em> statements.  </p>
  
  <p>Thanks in advance for any help.</p>