def My_fib(n): a = 1 b = 1 i = 1 while i <=n: if i <= 2: yield 1 else: c = a + b # a = b b = c yield c i+=1 D = My_fib(3) print(next(D)) print(next(D)) # for i in D: # print(i)