example-code-2e/17-it-generator/fibo_gen.py
2021-09-15 22:48:08 -03:00

8 lines
144 B
Python

from collections.abc import Iterator
def fibonacci() -> Iterator[int]:
a, b = 0, 1
while True:
yield a
a, b = b, a + b