+ 4
Explain (Code coach) Secret Message - Medium
I didn't get that
3 Answers
+ 3
You can do it by creating a dictionary of words indexed by the reverse of those words in the alphabet. And replacing the input words with their indexed value.
i.e dic ={'a':'z', 'b':'y'. ..}
+ 5
Thank you Justus for explaining the logic, How's my implementation!!!
m = input().lower()
s = 'abcdefghijklm nopqrstuvwxyz'
abc = list(s)
cba = abc[::-1]
for c in m:
print(cba[abc.index(c)],end='')
0
import string
words = input()
letters = list(words.lower())
#return place in alphabete based on inputs
y=[]
for x in letters:
if x== ' ':
y.append(x)
else:
y.append(string.ascii_lowercase.index(x))
#look up placement in reversed list
alphabet = string.ascii_lowercase
reversed = alphabet[::-1]
word=''
for i in y:
if i == ' ':
word += i
else:
word += reversed[i]
print(word)
Itâs probably contains some redundancy and unnecessary code but it answers the question!