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.
I wrote a Fibonacci function that prints every Fibonacci number under 3000.
def fibonacci():
a, b = 0, 1
while b < 3000:
a, b = b, a + b
print a
return a
How can I make it so it returns the first n Fibonacci numbers?
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:
a = str(fibonacci())
print a[6]
but that didn't work, and I'm not sure why. Thanks for helping.