Answer to Question #189795 in Python for phani

Question #189795
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'.


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

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

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
Sample Output 2
ulfmwzgrlmh
1
Expert's answer
2021-05-06T02:12:50-0400
def main():
    singleLine = input()
    secretMessage=""
    for l in singleLine:
        rl=reverseLetter(l)
        if(rl==""):
            secretMessage+=l
        else:
            secretMessage+=str(rl)


    print(secretMessage)


def reverseLetter(l):
    currentAlphabet = "abcdefghijklmnopqrstuvwxyz"
    currentAlphabetReverse = "zyxwvutsrqponmlkjihgfedcba"
    for i in range(0,len(currentAlphabet)):
        if l.islower() and l==currentAlphabet[i].lower():
            return currentAlphabetReverse[i]
    return ""




main()

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