human
Count of substrings of a Binary string containing only 1 s | Function to find the total number of substring having only ones.
Driver Code"
Solution in Python:
assistant
#Here is code to count of substrings of a Binary string containing only 1 s and the other steps required.
 def countOfSubstringWithOnlyOnes ( s ) :
	count = 0
	res = 0
	for i in range ( 0 , len ( s ) ) :
		if s [ i ] == '1' :
			count = count + 1
		else :
			count = 0 ;
		res = res + count
	return res
s = "0110111"
print ( countOfSubstringWithOnlyOnes ( s ) )