Python Program to Print the Fibonacci series


Using For loop

In [1]:
n = int(input("Please enter the positive length : "))

num1 = 0
num2 = 1

print("Fabonacci Series:")

for i in range(n):
    print(num1)
    next_number = num1 + num2
    num1,num2 = num2,next_number
Please enter the positive length : 10
Fabonacci Series:
0
1
1
2
3
5
8
13
21
34

In this program, the user is asked to input the length of the series. Then, a for loop is used to print the series by adding and swapping the numbers.