Mirror characters of a string | Function which take the given string and the position from which the reversing shall be done and returns the modified string ; Creating a string having reversed alphabetical order ; The string up to the point specified in the question , the string remains unchanged and from the point up to the length of the string , we reverse the alphabetical order ; Driver function
def compute ( st , n ) : NEW_LINE INDENT reverseAlphabet = " zyxwvutsrqponmlkjihgfedcba " NEW_LINE l = len ( st ) NEW_LINE answer = " " NEW_LINE for i in range ( 0 , n ) : NEW_LINE INDENT answer = answer + st [ i ] ; NEW_LINE DEDENT for i in range ( n , l ) : NEW_LINE INDENT answer = ( answer + reverseAlphabet [ ord ( st [ i ] ) - ord ( ' a ' ) ] ) ; NEW_LINE DEDENT return answer ; NEW_LINE DEDENT st = " pneumonia " NEW_LINE n = 4 NEW_LINE answer = compute ( st , n - 1 ) NEW_LINE print ( answer ) NEW_LINE