def Fib(): fn1, fn = 1, 0 while True: yield fn fn1, fn = fn, fn1 + fn f1 = Fib() f2 = Fib() for i in range( 10 ): print( next( f1 ), next( f2 ) ) # resume # Local Variables: # # tab-width: 4 # # compile-command: "python3.7 Fib2.py" # # End: #