Answer to Question #176102 in Python for jayanth

Question #176102

Secret Message - 1

Given a string, write a program to mirror the characters of the string in alphabetical order to create a secret message.


Note: Mirroring the characters in alphabetical order replacing the letters 'a' with 'z', 'b' with 'y', ... , 'z' with 'a'. You need to mirror both uppercase and lowercase characters. You can ignore mirroring for all characters that are not letters.


abcdefghijklmzyxwvutsrqpon nopqrstuvwxyzmlkjihgfedcbaInput


The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).Output


For example, if the 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 the output should be "kbgslm".

Sample Input 1

python

Sample Output 1

kbgslm

Sample Input 2

Foundations




1
Expert's answer
2021-03-28T23:49:30-0400
l1 = "abcdefghijklmnopqrstuvwxyz"
b1 = l1.upper()
l2 = "zyxwvutsrqponmlkjihgfedcba"
b2 = l2.upper()
table = "".maketrans(l1+b1, l2+b2)

while True:
   inp = input("Source string: ")
   if len(inp) == 0:
       break 
   print("Traslate: ", inp.translate(table))

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

chandra
16.05.21, 13:44

in line 8 error showing

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS