human
Number of ways to remove a sub | Function to return the number of ways of removing a sub - string from s such that all the remaining characters are same.
To store the count of prefix and suffix.
Loop to count prefix.
Loop to count suffix.
First and last characters of the string are same.
Otherwise.
Driver Code"
How can the above be solved in Python?

Write me a code to number of ways to remove a sub and the other steps required?
assistant
#Here is code to number of ways to remove a sub and the other steps required.
 def no_of_ways ( s ) :
	n = len ( s )
	count_left = 0
	count_right = 0
	for i in range ( 0 , n , 1 ) :
		if ( s [ i ] == s [ 0 ] ) :
			count_left += 1
		else :
			break
	i = n - 1
	while ( i >= 0 ) :
		if ( s [ i ] == s [ n - 1 ] ) :
			count_right += 1
		else :
			break
		i -= 1
	if ( s [ 0 ] == s [ n - 1 ] ) :
		return ( ( count_left + 1 ) * ( count_right + 1 ) )
	else :
		return ( count_left + count_right + 1 )
if __name__ == ' _ _ main _ _ ' :
	s = " geeksforgeeks "
	print ( no_of_ways ( s ) )