Answer to Question #197226 in Python for shiva

Question #197226

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


The output should be a single line containing the secret message. All characters in the output should be in lower case.

Explanation

.

Sample Input 1

python

output

kbgslm

sample 2

Foundations

output

ulfmwzgrlmh




1
Expert's answer
2021-05-23T12:18:35-0400
letters1='abcdefghijklm'
letters2='zyxwvutsrqpon'
s=input()
result=''
for x in s:
    if x.lower() in letters1:
        result=result+letters2[letters1.find(x.lower())]
    elif x.lower() in letters2:
        result = result + letters1[letters2.find(x.lower())]
print(result)

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS