So i have created a function which will essentially take a value as a parameter and run the fibonacci sequence. It tends to only print 1 each time i am using next. I am not sure why it is doing this. When it reached the yield keyword it returns back the value of 1. So far my code is as follows :
def fibonacci(n):
curr = 1
prev = 0
counter = 0
while counter < n:
yield curr
prev, curr = curr, prev + curr
counter += 1
print(next(fibonacci(10)))
print(next(fibonacci(10)))
print(next(fibonacci(10)))