human
Count and Print the alphabets having ASCII value not in the range [ l , r ] | Function to count the number of characters whose ascii value not in range [ l , r ].
Initializing the count to 0.
using map to pra character only once.
Increment the count if the value is less.
return the count.
Driver Code"
How can the above be solved in Python?
assistant
#Here is code to count and Print the alphabets having ASCII value not in the range [ l , r ] and the other steps required.
 def CountCharacters ( str , l , r ) :
	cnt = 0
	m = { }
	length = len ( str )
	for i in range ( 0 , length ) :
		if ( not ( l <= ord ( str [ i ] ) and ord ( str [ i ] ) <= r ) ) :
			cnt += 1
			if ord ( str [ i ] ) not in m :
				m [ ord ( str [ i ] ) ] = 0
				print ( str [ i ] , end = " ▁ " )
			m [ ord ( str [ i ] ) ] += 1
	return cnt
if __name__ == ' _ _ main _ _ ' :
	str = " geeksforgeeks "
	str = str . strip ( )
	l = 102
	r = 111
	print ( " Characters ▁ with ▁ ASCII ▁ values " , end = " " )
	print ( " not in the range [ l , r ] " , ▁ " in the given string are : " , ▁ end ▁ = ▁ " " )
	print ( " and their count is   " , CountCharacters ( str , l , r ) )