Given a 26 letter character set, which is equivalent to character set of English alphabet i.e. (abcd….xyz) and act as a relation. We are also given several sentences and we have to translate them with the help of given new character set.
New character set : qwertyuiopasdfghjklzxcvbnm Input : "utta" Output : geek Input : "egrt" Output : code
We have existing solution for this problem please refer Change string to a new character set link. We will solve this problem in python using Zip() method and Dictionary data structures. Approach is simple,
- Create a dictionary data structure where we will map original character set in english language with new given character set, zip(newCharSet,origCharSet) does it for us. It will map each character of original character set onto each given character of new character set sequentially and return list of tuples of pairs, now we convert it into dictionary using dict().
- Now iterate through original string and convert it into new string.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Change string to a new character set
- Change Object Display Name using __str__ function - Django Models | Python
- Python program to read character by character from a file
- Python | Insert character after every character pair
- Change your way to put logic in your code - Python
- Python | How to dynamically change text of Checkbutton
- Change current working directory with Python
- Python - Change Datatype of Tuple Values
- Python - Change type of key in Dictionary list
- Python - Change Keys Case in Dictionary
- Python | Ways to change keys in dictionary
- Python - Change button color in kivy using .kv file
- Python - Maximum consecutive elements percentage change
- Python - Specific case change in String List
- Python - Change kivy button size and position using kv file
- Python PyQt5 – How to change font and size of Status Bar Message
- Python | Change column names and row indexes in Pandas DataFrame
- Python | Counting sign change in list containing Positive and Negative Integers
- Python | Add leading K character
- Python | Character Encoding
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.