How to create the Fibonacci Sequence in Python
This blog post will go through how to create the famous Fibonacci sequence in Python.
Each number in the Fibonacci sequence is the sum of the previous two terms.
The sequence starts: 0, 1, 1, 2, 3, 5, 8, 13, … and carries on infinitely.
The Python code I used is:
The first two terms are entered into our list, then we specify the number of terms wanted in our sequence.
Next, we loop through from 2 to the number of terms we wanted appending the sum of the previous two terms.
Printing our list gives the first fifty terms of the Fibonacci sequence.