I need a python code that collects all even numbers separately, odd numbers separately and displaying into two separate totals. The range of numbers is 1-20

I am new to this language and I keep getting syntax errors, invalid statement errors etc.. So it would be great if you can write a description about the code as well.

Thanks in advance.

even_list = []
odd_list = []
li = range(1,21)
for i in range(len(li)):
    if i/2 == 0 :
    else :
print even_list
print odd_list

please show us what you have done.
Letting someone else write your homework for you will not allow you to learn much.

Mohit3 i think your if statement to find even numbers is wrong as any number of 2 or greater divided by 2 is going to give a higer result than 0.
You need to use modulo to find the numbers that are divisible exactly by 2. In python its %

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.