Python Practice › List Programs › Program 78
Fibonacci numbers from 1 to 20
Write a Python program to get the Fibonacci numbers between 1 and 20.
Output
[1, 1, 2, 3, 5, 8, 13]
Approach
- Generate the series and keep values from 1 to 20.
Solution
fib = []a, b = 1, 1while a <= 20: fib.append(a) a, b = b, a + bprint(fib)Output
[1, 1, 2, 3, 5, 8, 13]
Learn the concept
New to this topic? Read the lesson, then come back.