Count and Print the alphabets having ASCII value in the range [ l , r ] | Function to count the number of characters whose ascii value is in range [ l , r ] ; Initializing the count to 0 ; Increment the count if the value is less ; return the count ; Driver code
def CountCharacters ( str1 , l , r ) : NEW_LINE INDENT cnt = 0 ; NEW_LINE len1 = len ( str1 ) NEW_LINE for i in str1 : NEW_LINE INDENT if ( l <= ord ( i ) and ord ( i ) <= r ) : NEW_LINE INDENT cnt = cnt + 1 NEW_LINE print ( i , end = " ▁ " ) NEW_LINE DEDENT DEDENT return cnt NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT str1 = " geeksforgeeks " NEW_LINE l = 102 NEW_LINE r = 111 NEW_LINE print ( " Characters ▁ with ▁ ASCII ▁ values ▁ " + " in ▁ the ▁ range ▁ [ l , ▁ r ] ▁ are " ) NEW_LINE print ( " and their count is   " , CountCharacters ( str1 , l , r ) ) NEW_LINE DEDENT