How to make a fibonacci series with a Function in Python?

The Fibonacci series is complicated using a programming language, and writing a Python function that takes the limit as an argument of the Fibonacci series and prints until that limit given as an argument — is very challenging. After reading this article, you will know how to write a Python function that will generate a Fibonacci series till the limit you set as a function argument.

But what’s a Fibonacci series? A Fibonacci series is a series where the first term starts from 0 and the 2nd term is 1. For the third term, it’s simply the addition of the 1st and 2nd terms, so 0+1 = 1. For the 4th term, it’s the addition of the 2nd and 3rd terms, so 1+1 = 2. So this goes on and on, making an infinite series of numbers. The first 10 terms of a Fibonacci series are 0,1,1,2,3,5,8,13,21,34.

So, let’s start with the code. At first, let’s just simply put on the logic without making a function.


Next, we set up another variable for our while loop. We named it counter and set its value to 0 because our loop will work from 0. Remember that our objective is to make a function which will produce a Fibonacci series, and we have to set our parameter as the range or term of the series. As we didn’t set any function yet, we will carry out code logic with the alphabet “X”. 

To read more click here