Program to add even numbers in an empty list

In this program, we will add even numbers to an empty list.

Steps to solve the program
  1. Take a list as input and create an empty list.
  2. Use for loop to iterate over each number of the input list.
  3. If the number is even then add it to the empty list.
  4. Print the output.
				
					list1 = [2,3,5,76,9,0,16]
even = []

for val in list1:
    if val%2 == 0:
        even.append(val)
        
print("Even numbers: ",even)
				
			

Output :

				
					Even numbers:  [2, 76, 0, 16]
				
			

find the total number of special characters in a string

add odd numbers in an empty list from a given list

Leave a Comment