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
input2
python learning
output2
kbgslm ovzimrmt
def EncodeChar(ch):
if ch.isalpha():
return chr(ord('z') - ord(ch.lower()) + ord('a'))
else:
return ch
def EncodeString(source):
result = ''
for ch in source:
result += EncodeChar(ch)
return result
print(EncodeString(input()))
Comments
Leave a comment