Create a program that replaces each letter in a message with its corresponding letter in a backwards version of the English alph | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Create a program that replaces each letter in a message with its corresponding letter in a backwards version of the English alph

How am I gonna go about it pls

8th May 2022, 6:58 AM
Fortunate Oyeyemi
Fortunate Oyeyemi - avatar
5 Answers
+ 5
Fortunate Oyeyemi , besides the suggestions you already got, the task can be done also by using a dictionary. this has to be like: {'a': 'z', 'b': 'y', ..., 'z': 'a'}, and can be used as lookup table. by getting an input of 'a' it will return 'z', ... steps: - take an input - create a string variable with the letters from 'a ... z' - the dictionary can be created by using the dict() constructor, with the letter string and a reverse of the letter string, and put together by using the zip() function - now characters can be read from the input string using a for loop. each character is now used to get the reversed letter version from the dictionary. so we can create a new string. (this complete step can also be done with a list comprehension) - finally output of the new string
8th May 2022, 2:09 PM
Lothar
Lothar - avatar
+ 4
Fortunate Oyeyemi I had a look at your profile and can't see where you have commenced a Python tutorial, so I would suggest you start with Python for Beginners, followed by Intermediate Python. You will then know how to do this
8th May 2022, 7:25 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
I have already commenced a python tutorial so I'll just continue as u have suggested Thanks alot
8th May 2022, 8:08 AM
Fortunate Oyeyemi
Fortunate Oyeyemi - avatar
+ 2
Fortunate Oyeyemi List Slicing will provide your answer. Just remember that lists & strings can both be sliced, and manipulated using the same syntax
8th May 2022, 8:11 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Rik Wittkopp Ok Thanks Boss 🙇🙇
8th May 2022, 8:14 AM
Fortunate Oyeyemi
Fortunate Oyeyemi - avatar