title: How to get nth result from simple function in python?
body: <p>I apologize for the simplicity of this question, I have searched multiple times but it may be so simple it hasn't been asked before.</p>
  
  <p>I wrote a Fibonacci function that prints every Fibonacci number under 3000.</p>
  
  <pre><code>def fibonacci():
      a, b = 0, 1
      while b &lt; 3000:
          a, b = b, a + b
          print a
      return a
  </code></pre>
  
  <p>How can I make it so it returns the first n Fibonacci numbers?</p>
  
  <p>Also, how can I make it just print the nth value? For example print [6], which would return 8.
  I tried to make it a string:</p>
  
  <pre><code>a = str(fibonacci())
  print a[6]
  </code></pre>
  
  <p>but that didn't work, and I'm not sure why. Thanks for helping.</p>