Odd and even number lists


I am trying to list all odd and even numbers. I have it but it is dropping the 9 in the output.

numbers = [1,2,3,4,5,6,7,8,9]

listEven = []
listOdd = []

for numbers in range(1, len(numbers)):
if numbers % 2 == 0:


[1, 3, 5, 7]
[2, 4, 6, 8]

There should be a 9 in the first list. Please help me figure out what I am doing wrong.



Using an iterator variable that is the same name as the list we are iterating is the first indication of confusion. With the names at one’s disposal, is there no other name?

for number in numbers:

Iterate the terms, not a range.


You’re ignoring what’s in the list, if you put strings in the list instead you’ll find that none of them will show in your output


Thank you! It is now working for me.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.