Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

segregate list in even and odd numbers python

# program that splits even and odd digit from inputed list.
list=eval(input("list of digits"))
even_list=[]
odd_list=[]
for i in list :
    if i%2==0 :
        even_list.append(i)
    else:
        odd_list.append(i)
print('even list :',even_list)
print('odd list  :',odd_list)
--------------------------------------------------------------------------------
output:
list of digits[0,1,2,3,4,5,6,7,8,9]
even list : [0, 2, 4, 6, 8]
odd list  : [1, 3, 5, 7, 9]
--------------------------------------------------------------------------------
 
PREVIOUS NEXT
Tagged: #segregate #list #odd #numbers #python
ADD COMMENT
Topic
Name
6+3 =