Python Program to separate even and odd numbers in a list

Hello everyone! Welcome back to Here in the post am going to add one program which covers the python data-type list. Here I will separate all the even and odd numbers from a list to two different lists.

Master the basics of data analysis in Python. Expand your skillset by learning scientific computing with numpy.

Take the course on Introduction to Python on DataCamp here

Separate even and odd numbers in a list – Code Visualization

Program on Github


Separate even an odd numbers from a list and add them to new lists.


  • Read input number asking for length of the list using input()
  • Initialise an empty list numbers = []
  • Read each number using a for loop
  • In the for loop append each number to the list numbers
  • Create another two empty lists even_lst = [] and odd_lst = []
  • Now run another for loop to check the numbers in the list are divided by 2 or not
  • If the numbers are divided by 2, append those elements to even_lstelse append those to odd_lst
  • Print both the even_lst and odd_lst


Program on Github


Separate even and odd elements into 2 lists -
Separate even and odd elements into 2 lists –
Course Suggestion

Want to learn python with strong fundamentals? If yes, I strongly suggest you to take the course below.
Course: Fundamentals of Programming in Python


One comment

  1. raul fernando aillon salinas

    How about this approach:

    def split_even_odd(A):
    while True:
    if n>0 and pos<n:
    if A[pos] % 2==0:
    return even, A

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.