+ 4

Explain (Code coach) Secret Message - Medium

I didn't get that

26th Apr 2020, 5:56 AM
Subash
Subash - avatar
3 Respostas
+ 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'. ..}
26th Apr 2020, 6:29 AM
Justus
Justus - avatar
+ 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='')
26th Apr 2020, 6:48 AM
Subash
Subash - avatar
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!
4th Jan 2023, 8:38 AM
ken baumli
ken baumli - avatar