human
Calculate score for the given binary string | Function to return the score for the given binary string.
Traverse through string character.
Initialize current chunk 's size.
Get current character.
Calculate total chunk size of same characters.
Add / subtract pow ( chunkSize , 2 ) depending upon character.
Return the score.
Driver code"
How can the above be solved in Python?

What is a code to calculate score for the given binary string and the other steps required?
assistant
#Here is code to calculate score for the given binary string and the other steps required.
 def calcScore ( str ) :
	score = 0
	len1 = len ( str )
	i = 0
	while ( i < len1 ) :
		chunkSize = 1
		currentChar = str [ i ]
		i += 1
		while ( i < len1 and str [ i ] == currentChar ) :
			chunkSize += 1
			i += 1
		if ( currentChar == '1' ) :
			score += pow ( chunkSize , 2 )
		else :
			score -= pow ( chunkSize , 2 )
	return score
if __name__ == ' _ _ main _ _ ' :
	str = "11011"
	print ( calcScore ( str ) )