In this Python list program, we will get a list of Fibonacci numbers from 1 to 20 with the help of the below-given steps.
List of fibonacci numbers:
Steps to solve the program
- Create an empty list.
- Calculate the Fibonacci series of numbers from 1 to 20 using for loop with the range function.
- Add that series to the empty list.
- Print the list to see the result.
#Creating empty list
list1 = []
num1 = 0
num2 = 1
for i in range(1,21):
list1.append(num1)
n2 = num1+num2
num1 = num2
num2 = n2
#Printing output
print(list1)
Output :
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
144, 233, 377, 610, 987, 1597, 2584, 4181]
Related Articles
Python program to reverse all the numbers in a given list.
Python program to get palindrome numbers from a given list.
Python program to get a count of vowels in the given list.
Python program to get the list of prime numbers in a given list.
Python program to get a list with n elements removed from the left and right.
Python program to create a dictionary with two lists.