Python: Remove the characters which have odd index values of a given string
Remove odd index chars from a string.
Write a Python program to remove characters that have odd index values in a given string.
Sample Solution:
Python Code:
Sample Output:
ace pto
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Python program to remove characters at odd indices using slicing with a step of 2.
- Write a Python program to iterate over a string with enumerate() and select characters with even indices.
- Write a Python program to use list comprehension to filter out characters at odd positions and join them into a new string.
- Write a Python program to build a new string containing only characters from even index positions using a loop.
Go to:
Previous: Write a Python program to change a given string to a new string where the first and last chars have been exchanged.
Next: Write a Python program to count the occurrences of each word in a given sentence.
Python Code Editor:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.