📜  python代码示例在偶数和奇数之间拆分列表的程序

📅  最后修改于: 2022-03-11 14:45:09.746000             🧑  作者: Mango

代码示例1
# Python code to split into even and odd lists
l=[]
n=int(input("enter the  length of the list:"))
for i in range(1,n+1):
    a=int(input("enter element"))
    l.append(a)
print(l)
even=[]
odd=[]
for j in l:
    if j%2==0:
        even.append(j)
    else:
        odd.append(j)
print("even number ",even)
print("odd  number", odd)