human
Split the binary string into substrings with equal number of 0 s and 1 s | Function to return the count of maximum substrings str can be divided into.
To store the count of 0 s and 1 s.
To store the count of maximum substrings str can be divided into.
It is not possible to split the string.
Driver code"
How can the above be solved in Python?

Can you provide a code to split the binary string into substrings with equal number of 0 s and 1 s and the other steps required?
assistant
#Here is code to split the binary string into substrings with equal number of 0 s and 1 s and the other steps required.
 def maxSubStr ( str , n ) :
	count0 = 0
	count1 = 0
	cnt = 0
	for i in range ( n ) :
		if str [ i ] == '0' :
			count0 += 1
		else :
			count1 += 1
		if count0 == count1 :
			cnt += 1
	if cnt == 0 :
		return - 1
	return cnt
str = "0100110101"
n = len ( str )
print ( maxSubStr ( str , n ) )