human
Give me a code to check if both halves of a string are Palindrome or not and the other steps required given the following:
Check if both halves of a string are Palindrome or not | Function to check if both halves of a string are palindrome or not.
Length of string.
Initialize both part as true.
If first half is not palindrome.
If second half is not palindrome.
If both halves are palindrome.
Driver code"
Solution in Python:
assistant
#Here is code to check if both halves of a string are Palindrome or not and the other steps required.
 def checkPalindrome ( S ) :
	n = len ( S )
	first_half = True
	second_half = True
	cnt = ( n // 2 ) - 1
	for i in range ( 0 , int ( ( n / 2 ) / 2 ) ) :
		if ( S [ i ] != S [ cnt ] ) :
			first_half = False
			break
		if ( S [ n // 2 + i ] != S [ n // 2 + cnt ] ) :
			second_half = False
			break
		cnt -= 1
	if ( first_half and second_half ) :
		print ( ' Yes ' , end = ' ' )
	else :
		print ( ' No ' , end = ' ' )
if __name__ == ' _ _ main _ _ ' :
	S = ' momdad '
	checkPalindrome ( S )