human
Length of longest substring having all characters as K | Function to find the length of longest sub - string having all characters same as character K.
Initialize variables.
Iterate till size of string.
Check if current character is K.
Assingning the max value to max_len.
Driver code.
Function call"
How can the above be solved in Python?

=====
Can you provide a code to length of longest substring having all characters as K and the other steps required?
assistant
#Here is code to length of longest substring having all characters as K and the other steps required.
 def length_substring ( S , K ) :
	curr_cnt = 0
	prev_cnt = 0
	max_len = 0
	for i in range ( len ( S ) ) :
		if ( S [ i ] == K ) :
			curr_cnt += 1
		else :
			prev_cnt = max ( prev_cnt , curr_cnt )
			curr_cnt = 0
	prev_cnt = max ( prev_cnt , curr_cnt )
	max_len = prev_cnt
	return max_len
if __name__ == ' _ _ main _ _ ' :
	S = " abcd1111aabc "
	K = '1'
	print ( length_substring ( S , K ) )