human
Check if String formed by first and last X characters of a String is a Palindrome | Function to check whether the first x characters of both string str and reversed string str are same or not.
Length of the string str.
Traverse over the string while first and last x characters are not equal.
If the current and n - k - 1 from last character are not equal.
Finally , print true.
Driver Code.
Given input.
Function Call"
How can the above be solved in Python?
assistant
#Here is code to check if String formed by first and last X characters of a String is a Palindrome and the other steps required.
 def isEqualSubstring ( string , x ) :
	n = len ( string )
	i = 0
	while i < n and i < x :
		if ( string [ i ] != string [ n - i - 1 ] ) :
			print ( " false " )
			return
		i += 1
	print ( " true " )
	return
if __name__ == ' _ _ main _ _ ' :
	string = " GeeksforGeeks "
	x = 3
	isEqualSubstring ( string , x )