human
Minimum characters to be added at front to make string palindrome | function for checking string is palindrome or not.
Driver code.
if string becomes palindrome then break.
erase the last element of the string.
print the number of insertion at front"
Solution in Python:
assistant
#Here is code to minimum characters to be added at front to make string palindrome and the other steps required.
 def ispalindrome ( s ) :
	l = len ( s )
	i = 0
	j = l - 1
	while i <= j :
		if ( s [ i ] != s [ j ] ) :
			return False
		i += 1
		j -= 1
	return True
if __name__ == " _ _ main _ _ " :
	s = " BABABAA "
	cnt = 0
	flag = 0
	while ( len ( s ) > 0 ) :
		if ( ispalindrome ( s ) ) :
			flag = 1
			break
		else :
			cnt += 1
			s = s [ : - 1 ]
			s . erase ( s . begin ( ) + s . length ( ) - 1 ) ;
	if ( flag ) :
		print ( cnt )