In this example we will show how to delete the character of an even index value in a string with Python.
Source Code
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
def remove_even_index(string):
newStr = ""
for i in range(len(string)):
if i % 2 != 0:
newStr += string[i]
return newStr
str = input("Please input the string: ")
print("After deleting: ", remove_even_index(str))
Output:
Please input the string: Hello World
After deleting: el ol