In this program, we will take a user input as a list and differentiate even and odd elements with the help of the below-given steps.
Differentiate even and odd number in list:
Steps to solve the program
- Take a list as input and create two empty lists with names odd and even.
- Use for loop to iterate over each element of the given list.
- Use the if statement to check whether the element is even or not during iteration.
- If even add that element to the even list, if not add it to the odd list to differentiate even and odd numbers.
- Print both lists to see the output.
Output :
Related Articles
Python program to remove all duplicate elements from the list.
Python program to print a combination of 2 elements from the list whose sum is 10.
Python program to print squares of all even numbers in a list.
Python program to get common elements from two lists.
Python program to reverse a list with for loop.