Today we are going to share a **Python program to segregate even and odd elements of array**. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python program to segregate even and odd elements of array.

To increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.

Copy the below python program and execute it with the help of **python compiler**.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | def segregateEvenOdd(arr): # Initialize left and right indexes left,right = 0,len(arr)-1 while left < right: # Increment left index while we see 0 at left while (arr[left]%2==0 and left < right): left += 1 # Decrement right index while we see 1 at right while (arr[right]%2 == 1 and left < right): right -= 1 if (left < right): # Swap arr[left] and arr[right]*/ arr[left],arr[right] = arr[right],arr[left] left += 1 right = right-1 arr = [12, 34, 45, 9, 8, 90, 3] segregateEvenOdd(arr) print ("Array after segregation "), for i in range(0,len(arr)): print arr[i], |

Array after segregation 12 34 90 8 9 45 3

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

- Python File Methods
- Python program to add digits of a number
- Python program for subset sum problem
- Generating strong password using Python
- Download Google Images using Python Script
- Python examples on simple mathematical problems
- Program for adding two binary numbers
- Python Program to Solve n-Queen Problem with Recursion
- Python Program to Solve the Celebrity Problem
- Python Program to Solve n-Queen Problem without Recursion

We use cookies to ensure that we give you the best experience on our website. We and our partners are using technologies like cookies and process personal data like the IP-address or browser information in order to personalize the advertising that you see. This helps us to show you more relevant ads and improves your internet experience. Read more about our Privacy Policy.Got it!