Program to add odd numbers in an empty list

In this program, we will add odd 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 odd then add it to the empty list.
  4. Print the output.
				
					list1 = [3,8,5,0,2,7]
odd = []

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

Output :

				
					Even numbers:  [3, 5, 7]
				
			

add even numbers in an empty list from a given list

add special characters in an empty list from a given list 

Leave a Comment