Write a Python program to print the even numbers from a given list.
Sample List : [1, 2, 3, 4, 5, 6, 7, 8, 9]Expected Result : [2, 4, 6, 8]
numbers =[1, 2, 3, 4, 5, 6, 7, 8, 9]
evenNumbers=[]
# iterating each number in list
for num in numbers:
# checking condition
if num % 2 == 0:
evenNumbers.append(num)
print(evenNumbers)
Comments
Leave a comment