Count of alphabets having ASCII value less than and greater than k | Function to count the number of characters whose ascii value is less than k ; Initialising the count to 0 ; Incrementing the count if the value is less ; return the count ; Driver code
def CountCharacters ( str , k ) : NEW_LINE INDENT cnt = 0 NEW_LINE l = len ( str ) NEW_LINE for i in range ( l ) : NEW_LINE INDENT if ( ord ( str [ i ] ) < k ) : NEW_LINE INDENT cnt += 1 NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT str = " GeeksForGeeks " NEW_LINE k = 90 NEW_LINE count = CountCharacters ( str , k ) NEW_LINE print ( " Characters ▁ with ▁ ASCII ▁ values " , " less ▁ than ▁ K ▁ are " , count ) NEW_LINE print ( " Characters ▁ with ▁ ASCII ▁ values " , " greater ▁ than ▁ or ▁ equal ▁ to ▁ K ▁ are " , len ( str ) - count ) NEW_LINE DEDENT