Python Program to print Odd and Even numbers from the list of integers

In this article, we are going to discover odd and even numbers from the given

rundown of whole numbers utilizing Python program.

Rationale: To do this, we will just experience the rundown and check whether the number is distinct by 2 or not, in the event

that it is detachable by 2, at that point the number is EVEN else it is ODD.

Program

# Give number of elements present in list
n=int(input())

# list
l= list(map(int,input().strip().split(" ")))

# the number will be odd if on diving the number by 2 
# its remainder is one otherwise number will be even
odd=[]
even=[]

for i in l:
    if(i%2!=0):
        odd.append(i)
    else:
        even.append(i)

print("list of odd number is:",odd)
print("list of even number is:",even)

Output

Python Program to print Odd and Even numbers from the list of integers

Leave a Comment

error: Alert: Content is protected!!