I solved this question through this method but it is not good method anyone can help me to solve this question . To other method | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

I solved this question through this method but it is not good method anyone can help me to solve this question . To other method

You are trying to send a secret message, and you've decided to encode it by replacing every letter in your message with its corresponding letter in a backwards version of the alphabet. What do your messages look like? Task: Create a program that replaces each letter in a message with its corresponding letter in a backwards version of the English alphabet. Input Format: A string of your message in its normal form. Output Format: A string of your message once you have encoded it (all lower case). Sample Input: Hello World Sample Output: svool dliow ###### solution#### a_z={"z":"a", "y":"b", "x":"c", "w":"d", "v":"e", "u":"f", "t":"g", "s":"h", "r":"i", "q":"j", "p":"k", "o":"l", "n":"m", "m":"n", "l":"o", "k":"p", "j":"q", "i":"r", "h":"s", "g":"t", "f":"u", "e":"v", "d":"w", "c":"x", "b":"y", "a":"z" } result="".join(a_z.get(word,word) for word in input().lower() ) print(result)

3rd Jul 2021, 4:34 AM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar
39 Answers
+ 2
firstly, number of lines in code is not necessarly related to time consuming, and secondly, you are still using few lines of code ^^
3rd Jul 2021, 4:46 AM
visph
visph - avatar
+ 8
Here's a simple one-liner solution to your problem: https://code.sololearn.com/cQpVf2uPolQh/?ref=app
3rd Jul 2021, 4:29 PM
Calvin Thomas
Calvin Thomas - avatar
+ 4
not so much time consuming, and improvments would only be unnoticeable ;)
3rd Jul 2021, 4:44 AM
visph
visph - avatar
+ 3
import string abc=string. ascii_lowercase a_z= dict(zip(abc, abc[::-1])) prevents from typo
3rd Jul 2021, 4:56 AM
Oma Falk
Oma Falk - avatar
+ 2
But some people solve this problem few line of code
3rd Jul 2021, 4:45 AM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar
+ 2
visph wise words๐Ÿ˜Š
3rd Jul 2021, 5:05 AM
Oma Falk
Oma Falk - avatar
+ 1
other method related to what? at least provide your actual code (better to give us a link to a code playground) if you want to have "other methods" ^^
3rd Jul 2021, 4:38 AM
visph
visph - avatar
+ 1
you have only three lines of code (if you do not count empty lines, and put the alone closing parenthesis next to lower()), and you could have only two lines by avoiding use of 'result' variable (by directly printing result of 'join' call)
3rd Jul 2021, 4:52 AM
visph
visph - avatar
+ 1
you are comparing two different languages, that's not comparable ^^
3rd Jul 2021, 4:53 AM
visph
visph - avatar
+ 1
Oma Falk prevent typo, but could confuse OP: he must know how zip function works to use it ^^ [edit] and must be aware of string.ascii_lowercase ;P
3rd Jul 2021, 5:00 AM
visph
visph - avatar
+ 1
visph it is worth to learn. zip is very cool.
3rd Jul 2021, 5:02 AM
Oma Falk
Oma Falk - avatar
+ 1
Oma Falk there are lot of cool stuff in built-in modules... each one would learn any of them at their times ;P
3rd Jul 2021, 5:04 AM
visph
visph - avatar
+ 1
Why are people down voting?
4th Jul 2021, 4:34 AM
Henry Kamulanje ๐Ÿ‡ฒ๐Ÿ‡ผ
Henry Kamulanje ๐Ÿ‡ฒ๐Ÿ‡ผ - avatar
+ 1
Kamulanje ๐Ÿ‡ฒ๐Ÿ‡ผ Irrelevant and off-topic comments in the Q&A will be considered as spam and thus, be downvoted.
4th Jul 2021, 5:03 AM
Calvin Thomas
Calvin Thomas - avatar
+ 1
Here's a simple one-liner solution to your problem: https://code.sololearn.com/cQpVf2uPolQh/?ref=app
4th Jul 2021, 12:33 PM
Chetan Jain
Chetan Jain - avatar
0
Ok
3rd Jul 2021, 4:39 AM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar
0
your method is good... why do you think it's not?
3rd Jul 2021, 4:41 AM
visph
visph - avatar
3rd Jul 2021, 4:42 AM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar
0
Oo
3rd Jul 2021, 4:44 AM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar
0
Ok
3rd Jul 2021, 4:44 AM
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ
๐—ฃ๐—ฎ๐˜„๐—ฎ๐—ป ๐—ž๐˜‚๐—บ๐—ฎ๐—ฟ ๐Ÿ…Ÿ๏ธŽ๐Ÿ…š๏ธŽ - avatar