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.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- Change string to a new character set
- zip() in Python
- Python | Zip different sized list
- Python | Zip Uneven Tuple
- Application to get address details from zip code Using Python
- Working with zip files in Python
- Get Zip Code with given location using GeoPy in Python
- Create pandas dataframe from lists using zip
- PYGLET – Creating ZIP Location Object
- Python | Insert character after every character pair
- Python program to read character by character from a file
- Longest Common Prefix using Character by Character Matching
- Find a string such that every character is lexicographically greater than its immediate next character
- Replace every character of string by character whose ASCII value is K times more than it
- Count substrings that starts with character X and ends with character Y
- Replace every character of a string by a different character
- Shortest distance to every other character from given character
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Map every character of one string to another such that all occurrences are mapped to the same character
- Modify the string such that every character gets replaced with the next character in the keyboard
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.