human
Count of lexicographically smaller characters on right | Function to count the smaller characters on the right of index i.
store the length of String.
initialize each elements of arr to zero.
array to store count of smaller characters on the right side of that index.
initialize the variable to store the count of characters smaller than that at index i.
adding the count of characters smaller than index i.
print the count of characters smaller than index i stored in ans array.
Driver Code"
How can the above be solved in Python?

Write me a code to count of lexicographically smaller characters on right and the other steps required?
assistant
#Here is code to count of lexicographically smaller characters on right and the other steps required.
 def countSmaller ( str ) :
	n = len ( str ) ;
	arr = [ 0 ] * 26 ;
	ans = [ 0 ] * n ;
	for i in range ( n - 1 , - 1 , - 1 ) :
		arr [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1 ;
		ct = 0 ;
		for j in range ( ord ( str [ i ] ) - ord ( ' a ' ) ) :
			ct += arr [ j ] ;
		ans [ i ] = ct ;
	for i in range ( n ) :
		print ( ans [ i ] , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
	str = " edcbaa " ;
	countSmaller ( str ) ;