Answer to Question #284430 in Python for vaibhav

Question #284430

 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]


1
Expert's answer
2022-01-03T04:28:16-0500
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS