Check if a given string is Even | Function to check if the string str is palindromic or not ; Pointers to iterate the string from both ends ; If characters are found to be distinct ; Return true if the string is palindromic ; Function to generate string from characters at odd indices ; Function to generate string from characters at even indices ; Functions to checks if string is Even - Odd Palindrome or not ; Generate odd indexed string ; Generate even indexed string ; Check for Palindrome ; Driver code
def isPalindrome ( Str ) : NEW_LINE INDENT l = 0 NEW_LINE h = len ( Str ) - 1 NEW_LINE while ( h > l ) : NEW_LINE INDENT if ( Str [ l ] != Str [ h ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT l += 1 NEW_LINE h -= 1 NEW_LINE DEDENT return True NEW_LINE DEDENT def makeOddString ( Str ) : NEW_LINE INDENT odd = " " NEW_LINE for i in range ( 1 , len ( Str ) , 2 ) : NEW_LINE INDENT odd += Str [ i ] NEW_LINE DEDENT return odd NEW_LINE DEDENT def makeevenString ( Str ) : NEW_LINE INDENT even = " " NEW_LINE for i in range ( 0 , len ( Str ) , 2 ) : NEW_LINE INDENT even += Str [ i ] NEW_LINE DEDENT return even NEW_LINE DEDENT def checkevenOddPalindrome ( Str ) : NEW_LINE INDENT odd = makeOddString ( Str ) NEW_LINE even = makeevenString ( Str ) NEW_LINE if ( isPalindrome ( odd ) and isPalindrome ( even ) ) : NEW_LINE INDENT print ( " Yes " ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( " No " ) NEW_LINE DEDENT DEDENT Str = " abzzab " NEW_LINE checkevenOddPalindrome ( Str ) NEW_LINE