...
/Solution Review: Creating Fibonacci Sequence Using Generator
Solution Review: Creating Fibonacci Sequence Using Generator
This lesson explains the solution for the "Fibonacci generator" problem.
We'll cover the following...
Solution
Press + to interact
def fib_gen(n):x, y = 0, 1for _ in range(n):yield xx, y = y, x + yn = 10gen = fib_gen(n)print(list(gen))
Explanation
The first thing we need to ...