Create a program that replaces each letter in a message with its corresponding letter in a backwards version of the English alph
5 Answers
New AnswerHow am I gonna go about it pls
5/8/2022 6:58:45 AM
Fortunate Oyeyemi5 Answers
New AnswerFortunate 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
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
I have already commenced a python tutorial so I'll just continue as u have suggested Thanks alot
Fortunate Oyeyemi List Slicing will provide your answer. Just remember that lists & strings can both be sliced, and manipulated using the same syntax
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message