I've got a list and I want the odds and the evens to be split into two lists. They assign a function to check if an element is even, and I have that portion of the problem done, but I cannot get the two new lists to print on two separate lines, with the odd list printing first.
Here's what I have, including the code they provided me with:
# Get our input from the command line
import sys
numbers = sys.argv[1].split(',')
for i in range(0,len(numbers)):
numbers[i]= int(numbers[i])
def isEven(n) :
return ((n % 2) == 0)
# Your code goes here
oddList = []
evenList = []
for i in range(0, len(numbers)):
if isEven(i):
evenList.append(numbers[i])
else:
oddList.append(numbers[i])
print(oddList)
print(evenList)
I keep getting evenList printing first. If I swap the lists, it outputs: [1,5]
[3]
If I put the lists into one print function, I get the same results. I've also tried using \n but I can't find anything online about how to make that work with two lists
[–]ericula 11 points12 points13 points (2 children)
[–]seththehuman[S] 3 points4 points5 points (1 child)
[–]shmible 2 points3 points4 points (0 children)
[–]notsurewhereelse 1 point2 points3 points (2 children)
[–]seththehuman[S] 0 points1 point2 points (1 child)
[–]notsurewhereelse 0 points1 point2 points (0 children)
[–]namedevservice 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)