Python Program to Print Even Numbers in a List

• Print all Even Numbers in a List of 10 Elements (Numbers)
• Print all Even Numbers in a List of n Numbers

Print Even Numbers in a List

The question is, write a Python program to print all even numbers (if available) in a given list. The program given below is answer to this question:

numList = []
print("Enter 10 Numbers: ")
for i in range(10):
numList.insert(i, int(input()))

print("\nEven Numbers:")
for i in range(10):
if numList[i]%2==0:
print(numList[i])

Here is the initial output of this program's sample run:

Now supply the input as ten numbers say 1, 4, 7, 8, 9, 10, 11, 14, 54, 23, to find and print all even numbers from given list as shown in the snapshot given below:

Print all Even Numbers in a List of n Numbers

This is the modified version of previous program. This program allows user to define the size of list. Let's have a look at the program and its sample run given below:

arr = list()
chk = 0
print(end="Enter the Size of List: ")
arrSize = int(input())
print(end="Enter " +str(arrSize)+ " Numbers: ")
for i in range(arrSize):
arr.append(int(input()))
if arr[i]%2==0:
chk = 1

if chk==0:
print("\nEven number is not available in the List!")
else:
print(end="\nEven Numbers: ")
for i in range(arrSize):
if arr[i]%2==0:
print(end=str(arr[i]) +" ")
print()

Here is its sample run with user input, 6 as size and 5, 6, 7, 8, 9, 10 as five numbers:

Here is another sample run with user input 4 as size and 5, 7, 9, 11 as four numbers:

Python Online Test

« Previous Program Next Program »