Remove odd indexed characters from a given string | Function to remove the odd indexed characters from a given string ; Stores the resultant string ; If the current index is odd ; Skip the character ; Otherwise , append the character ; Return the modified string ; Driver Code ; Remove the characters which have odd index
def removeOddIndexCharacters ( s ) : NEW_LINE INDENT new_s = " " NEW_LINE i = 0 NEW_LINE while i < len ( s ) : NEW_LINE INDENT if ( i % 2 == 1 ) : NEW_LINE INDENT i += 1 NEW_LINE continue NEW_LINE DEDENT new_s += s [ i ] NEW_LINE i += 1 NEW_LINE DEDENT return new_s NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str = " abcdef " NEW_LINE str = removeOddIndexCharacters ( str ) NEW_LINE print ( str ) NEW_LINE DEDENT