title: Python generator initialize- 2 ways ,different outputs
body: <p>I am using python 3.3.3. i am learning generator and as far as I have gone, I have learnt two ways to initialize a generator.</p>
  
  <ol>
  <li><p>using generator comprehension</p>
  
  <pre><code>gen1 = (i * i for i in range(6))
  </code></pre></li>
  <li><p>using function and yield</p>
  
  <pre><code>def fib():
      a,b=0,1
      while True:
          yield a
          a,b=b,a+b
  gen2=fib()
  </code></pre></li>
  </ol>
  
  <p>now when i use next(gen1) again and again, i get 0,1,4,9,... as output.
  but when i use next(fib()) again and again, i get 0, 0 ,0,0 as output. i was thinking the output should be instead 0,1,1,2,3,5,....</p>
  
  <pre><code>print(next(fib())
  print(next(fib())
  print(next(fib())
  print(next(fib())
  </code></pre>
  
  <p>is the code that prints 0,0,0,0</p>