Python Practice › List Programs › Program 78

Fibonacci numbers from 1 to 20

EasyList Programs · 78 of 100

Write a Python program to get the Fibonacci numbers between 1 and 20.

Advertisement
Output
[1, 1, 2, 3, 5, 8, 13]

Approach

  1. Generate the series and keep values from 1 to 20.

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment