Exercise: Creating Fibonacci Sequence Using Generator
Use what you've learned so far to create a Fibonacci generator.
We'll cover the following
Problem statement
In this exercise, you will create the Fibonacci sequence using a generator.
Therefore, your task is to write the fib_gen()
function which takes in a positive integer, n
, and creates a Fibonacci sequence of range n
using a generator.
Input
n = 10
Output
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
Challenge
This problem has been designed for you to practice freely, so try to solve it on your own first. Take some time and think about the different concepts that we’ve explored in the course so far.
If you feel stuck, you can always check out the solution review provided in the next lesson.
Good luck!
Get hands-on with 1400+ tech skills courses.