Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python program to print even numbers in a list

#Python program to print
#even numbers in a list using recursion
def evennumbers(list, n=0):
    #base case
    if n==len(list):
        exit()
    if list[n]%2==0:
        print(list[n], end=" ")
    #calling function recursively
    evennumbers(list, n+1)
list1 = [10, 21, 4, 45, 66, 93]
print("Even numbers in the list:", end=" ")
evennumbers(list1)
#this code is contributed by Shivesh Kumar Dwivedi
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #Python #program #print #numbers #list
ADD COMMENT
Topic
Name
1+3 =