Restore original String from given Encrypted String by the given operations | Function to decrypt and print the original strings ; If length is exceeded ; Reverse the string ; Driver Code
def decryptString ( s , N ) : NEW_LINE INDENT for i in range ( 0 , len ( s ) , 2 * N ) : NEW_LINE INDENT if ( i + N < len ( s ) ) : NEW_LINE INDENT end = s [ i + N ] NEW_LINE DEDENT if ( i + N > len ( s ) ) : NEW_LINE INDENT end = s [ - 1 ] NEW_LINE DEDENT if ( i == 0 ) : NEW_LINE INDENT s = s [ i + N - 1 : : - 1 ] + s [ i + N : ] NEW_LINE DEDENT else : NEW_LINE INDENT s = s [ : i ] + s [ i + N - 1 : i - 1 : - 1 ] + s [ i + N : ] NEW_LINE DEDENT DEDENT print ( s ) NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s = " ihTs ▁ suohld ▁ ebeas ! y " NEW_LINE N = 3 NEW_LINE decryptString ( s , N ) NEW_LINE DEDENT