human
Longest substring that starts with X and ends with Y | Function returns length of longest substring starting with X and ending with Y.
Length of string.
Find the length of the string starting with X from the beginning.
Find the length of the string ending with Y from the end.
Longest substring.
Print the length.
Driver Code.
Given string str.
Starting and Ending characters.
Function Call"
Solution in Python:
assistant
#Here is code to longest substring that starts with X and ends with Y and the other steps required.
 def longestSubstring ( str , X , Y ) :
	N = len ( str )
	start = 0
	end = N - 1
	xPos = 0
	yPos = 0
	while ( True ) :
		if ( str [ start ] == X ) :
			xPos = start
			break
		start += 1
	while ( True ) :
		if ( str [ end ] == Y ) :
			yPos = end
			break
		end -= 1
	length = ( yPos - xPos ) + 1
	print ( length )
if __name__ == " _ _ main _ _ " :
	str = " HASFJGHOGAKZZFEGA "
	X = ' A '
	Y = ' Z '
	longestSubstring ( str , X , Y )