sort odd and even ascending order numbers in separate lists

Solutions on MaxInterview for sort odd and even ascending order numbers in separate lists by the best coders in the world

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