## DEV Community is a community of 603,019 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# Day 6 of 100DaysOfCode: Python Code to Find Even and Odd Numbers From List

Durga Pokharel ・1 min read

This is my 6th day of 100daysofcoding. I continue to learn from Coursera Python Data Structure course and also did some assignments. I tired to write code to find even and odd numbers from list. My code is right below.
My Solution

• Create a empty dictionary
• Give list of numbers
• Loop through each numbers and find out even numbers and keep it in even list similarly find odd numbers and keep it in odd list.
``````my_dict = {}
numbers = list(range(1,11))
even = []
odd = []
for n in numbers:
if n % 2 == 0:
even.append(n)
else:
odd.append(n)

my_dict["odd"] = odd
my_dict["even"] = even
print(my_dict)
``````

## Discussion (4)

Otu Michael • Edited

Code looks fun. I am sure you have come across the concept of functions, modules and how to use `return`. Try using functions and add a unit test for the function. You can have a separate file for testing or keep the code (function) in the same file as the test.

Durga Pokharel

This is great idea. Will try it. Thanks

Aabishkar Wagle

Nice. Keep it up. May be you can try implementing more advance data structures in coming days. 😀