def fib(a=0, b=1): while True: yield a a, b = b, a + b fib = iter(fib(1, 2)) fibs = [next(fib) for i in range(10)] print(fibs)
To embed this project on your website, copy the following code and paste it into your website's HTML: