human
Count consonants in a string ( Iterative and recursive methods ) | Function to check for consonant.
To handle lower case.
To count total number of consonants from 0 to n - 1.
Driver code"
Solution in Python:
 ... Can you provide a code to count consonants in a string ( Iterative and recursive methods ) and the other steps required?
assistant
#Here is code to count consonants in a string ( Iterative and recursive methods ) and the other steps required.
 def isConsonant ( ch ) :
	ch = ch . upper ( )
	return not ( ch == ' A ' or ch == ' E ' or ch == ' I ' or ch == ' O ' or ch == ' U ' ) and ord ( ch ) >= 65 and ord ( ch ) <= 90
def totalConsonants ( string , n ) :
	if n == 1 :
		return isConsonant ( string [ 0 ] )
	return totalConsonants ( string , n - 1 ) + isConsonant ( string [ n - 1 ] )
string = " abc ▁ de "
print ( totalConsonants ( string , len ( string ) ) )