Python

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.

Show us what you have done, we may try to help you. But we will not do your own homework.

odd_list = []

li = range(1,21)

for i in range(len(li)):

if i/2 == 0 :

even_list.append(li[i])

else :

odd_list.append(li[i])

print even_list

print odd_list

This is what I did but keep getting invalid syntax and no output

the word print gets highlighted

>>>print even_list

[]

>>>print odd_list

[]

There is no output

remainderof theinteger divisionbetween two integers.For example :

9 / 3 = 3 => 9 % 3 = 0 (0 is the remainder of the integer division between 9 and 3)

5 / 2 = 2 => 5 % 2 = 1 (because 5 = (2 * 2) +

1)More info here.