I'm not a python specialist, but maybe
even_list = []
odd_list = []
li = range(1,21)
for i in li:
if i%2 == 0 :
even_list.append(li[i])
else :
odd_list.append(li[i])
print even_list
print odd_list
Considerations:
- here you need the elements in li, not their indices; thus
for i in li:
instead of
for i in range(len(li)):
- the function to test whether a number is odd or even is modulo, not division.
Hope this helps. Let us know what this piece of code is giving.