Write a Python Program to Put Even and Odd elements in a List into Two Different Lists


Topic: Write a Python Program to Put Even and Odd elements in a List into Two Different Lists

Solution

a=[2, 3, 8, 9, 2, 4, 6]
even=[]
odd=[]
for j in a:
    if(j%2==0):
        even.append(j)
    else:
        odd.append(j)
print("The even list",even)
print("The odd list",odd)



List all Python Programs