sort odd and even ascending order numbers in separate lists code example
Example: sort odd and even ascending order numbers in separate lists
sort odd and even ascending numbers into seperate lists
numbers = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
def isEven(n) :
return ((n % 2) == 0)
oddnumbers = []
evennumbers = []
for i in numbers:
if isEven(i) == True:
evennumbers.append(i)
else:
oddnumbers.append(i)
print(oddnumbers)
print(evennumbers)