I'm trying to sort a list in order from odd to even but when I pass it through and assert statements it only works on a few assert statements. Looking at the print output everything should be working as its in the right order from odd to even but its failing the assert statements.
def oddsBeforeEvens(theList):
odd = []
even = []
for x in theList:
if x % 2 == 0:
even.append(x)
else:
odd.append(x)
theList = odd + even
aList = [-1, 0, 1, 2, 3, 4, 5, -6, -7]
oddsBeforeEvens(aList)
print(aList) # Debugging print
assert(aList[0] % 2 != 0) # odd integer
assert(aList[1] % 2 != 0)
assert(aList[2] % 2 != 0)
assert(aList[3] % 2 != 0)
assert(aList[4] % 2 != 0) # odd integer
assert(aList[5] % 2 == 0) # even integer
assert(aList[6] % 2 == 0)
assert(aList[7] % 2 == 0)
assert(aList[8] % 2 == 0) # even integer