Secret Message - 1
Given a string, write a program to mirror characters of string in alphabetical order to create a secret message.
a b c d e f g h i j k l m
z y x w v u t s r q p o n
n o p q r s t u v w x y z
m l k j i h g f e d c b a
Input
Input will be a string in the single line containing spaces and letters both uppercase and lowercase.
Output
Output should be a single line containing secret message. All characters in the output should be in lower case.
Explanation
For example, if given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So output be "kbgslm".
Sample Input 1
python
Sample Output 1
kbgslm
Sample Input 2
Foundations
Sample Output 2
ulfmwzgrlmh
alphabet="abcdefghijklmnopqrstuvwxyz"
alpha_upper=alphabet.upper()
secret_key="zyxwvutsrqponmlkjihgfedcba"
secret_upper=secret_key.upper()
table="".maketrans(alphabet+alpha_upper, secret_key+secret_upper)
myString=input("Enter the source string: ")
print("Secret message: ",myString.translate(table).lower())
Comments
Leave a comment