human
Split a given string into substrings of length K with equal sum of ASCII values | Function for checking string.
Check if the string can be split into substrings of K length only.
Compute the sum of first substring of length K.
Compute the sum of remaining substrings.
Check if sum is equal to that of the first substring.
Since all sums are not equal , return False.
All sums are equal , Return true.
All substrings cannot be of size K.
Driver code"
How can the above be solved in Python?

Give me a code to split a given string into substrings of length K with equal sum of ASCII values and the other steps required?
assistant
#Here is code to split a given string into substrings of length K with equal sum of ASCII values and the other steps required.
 def check ( str , K ) :
	if ( len ( str ) % K == 0 ) :
		sum = 0
		for i in range ( K ) :
			sum += ord ( str [ i ] ) ;
		for j in range ( K , len ( str ) , K ) :
			s_comp = 0 ;
			for p in range ( j , j + K ) :
				s_comp += ord ( str [ p ] ) ;
			if ( s_comp != sum ) :
				return False ;
		return True ;
	return False ;
K = 3 ;
str = " abdcbbdba " ;
if ( check ( str , K ) ) :
	print ( " YES " )
else :
	print ( " NO " )