Monday, 6 November 2023

Create a list a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a python program that prints out all the elements of the list that are less than 5

 

Create a list a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] and write a python program that prints out all the elements of the list that are less than 5  

a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]

 

# Iterate through the list and print elements less than 5

for element in a:

    if element < 5:

        print(element)