Raau :
Is there a way on how to only show the Nth number? e.g. I want the 15th Fibonacci Number, but this only gives lists.
a = int(input('Enter N Number: '))
def fib(n):
a = b = 1
for i in range(n):
yield a
a, b = b, a + b
print(fib(a))
AK47 :
Convert the result of fib()
to a list and index it at -1
:
print(list(fib(a))[-1])
>> Enter N Number: 15
>> [610]