Program to Encrypt a String using ! and @ | Function to encrypt the string ; evenPos is for storing encrypting char at evenPosition oddPos is for storing encrypting char at oddPosition ; Get the number of times the character is to be repeated ; if i is odd , print ' ! ' else print '@ ; Driver code ; Encrypt the String
def encrypt ( input_arr ) : NEW_LINE INDENT evenPos = ' @ ' ; oddPos = ' ! ' ; NEW_LINE for i in range ( len ( input_arr ) ) : NEW_LINE INDENT ascii = ord ( input_arr [ i ] ) ; NEW_LINE repeat = ( ascii - 96 ) if ascii >= 97 else ( ascii - 64 ) ; NEW_LINE for j in range ( repeat ) : NEW_LINE DEDENT DEDENT ' NEW_LINE INDENT if ( i % 2 == 0 ) : NEW_LINE INDENT print ( oddPos , end = " " ) ; NEW_LINE DEDENT else : NEW_LINE INDENT print ( evenPos , end = " " ) ; NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT input_arr = [ ' A ' , ' b ' , ' C ' , ' d ' ] ; NEW_LINE encrypt ( input_arr ) ; NEW_LINE DEDENT