Python 3 program to remove characters from odd or even index from a string :
In this example, we will write one program in Python 3 to remove all characters positioned on Even or Odd. We will ask the user if he wants to remove odd or even indexed characters. We are going to use the below algorithm in this program :
Algorithm to remove odd or even index character from a string :
1. First take the string from the user.
2. Create one variable empty string to store the output.
3. Ask the user if he wants to remove odd or even positioned characters from the string
4. Using a loop, iterate through the string. Add the character of even or odd position to the output string.
5. Print the output string.
Python 3 Program :
Download the below example program from here.
Sample Output :
In the above example, we are removing characters from ‘Hello’. The position of each character are :
H - 1 e - 2 l - 3 l - 4 o - 5
So, the string after removing odd index characters is ‘el’. And the string after removing even index characters is: ‘Hlo’.