human
Give me a code to count of substrings consisting of even number of vowels and the other steps required given the following:
Count of substrings consisting of even number of vowels | Utility function to check if a character is a vowel.
Function to calculate and return the count of substrings with even number of vowels.
Stores the count of substrings with even and odd number of vowels respectively.
Update count of vowels modulo 2 in sum to obtain even or odd.
Increment even / odd count.
Count substrings with even number of vowels using Handshaking Lemma.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count of substrings consisting of even number of vowels and the other steps required.
 def isVowel ( c ) :
	if ( c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' ) :
		return True ;
	return False ;
def countSubstrings ( s , n ) :
	temp = [ 1 , 0 ] ;
	result = 0 ;
	sum = 0 ;
	for i in range ( 0 , n ) :
		sum += ( 1 if isVowel ( s [ i ] ) else 0 ) ;
		sum %= 2 ;
		temp [ sum ] += 1 ;
	result += ( ( temp [ 0 ] * ( temp [ 0 ] - 1 ) ) // 2 ) ;
	result += ( ( temp [ 1 ] * ( temp [ 1 ] - 1 ) ) // 2 ) ;
	print ( result ) ;
if __name__ == ' _ _ main _ _ ' :
	n = 5 ;
	s = " abcde " ;
	countSubstrings ( s , n ) ;