title: Python iterator returning unwanted 'None'
body: <p>Why is my iterator returning extra 'None' in the output.  For the parameters/example below, I am getting <code>[None,4,None]</code> instead of the desired <code>[4]</code>  Can anyone explain why I am getting the extra None and how I can fix it?  The print out 'returning' only appears once so I am assuming only one item should be appended to the returning calling function.</p>
  
  <p>code:</p>
  
  <pre><code>class Prizes(object):
      def __init__(self,purchase,n,d):
          self.purchase = purchase
          self.length = len(purchase)
          self.i = n-1
          self.n = n
          self.d = d
  
      def __iter__(self):
          return self
  
      def __next__(self):
          if self.i &lt; self.length:
              old = self.i
              self.i += self.n
              if (self.purchase[old])%(self.d) == 0:
                  print("returning")
                  return old+1
          else:
              raise StopIteration
  
  def superPrize(purchases, n, d):
      return list(Prizes(purchases, n, d))
  
  purchases = [12, 43, 13, 465, 1, 13]
  n = 2
  d = 3
  print(superPrize(purchases, n, d))
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>returning
  [None, 4, None]
  </code></pre>