## Monday, May 17, 2021

Solution Exercise 26: python algorithm which determines the list of even integers and the list of odd integers from a given list #### Exercise 26

For a given list L of integers, write an algorithm in Python that return the tuple of lists (l_even, l_odd) where l_even designates the list of even integers of L and l_odd designates the list of odd integers of L. Example for L = [11, 3, 22, 14, 31, 18, 12, 7] the program returns the pair of lists: ([22, 14, 18, 12], [11, 3, 31, 7])

#### Solution

``````def oddEven (L):
# initialization of even and odd integer lists
l_even = []
l_odd = []
for n in L:
if n% 2 == 0:
l_even.append (n)
else:
l_odd.append (n)
return (l_even, l_odd)

#Example
L = [11, 3, 22, 14, 31, 18, 12, 7]
print (oddEven (L)) # the output is: ([22, 14, 18, 12], [11, 3, 31, 7])``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 