- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Zip function in Python to change to a new character set.
Given a 26 letter character set, here we are using a new character set. And another character set just like alphabet set (a, b, c........z), then our task is to make a relation between new character set and that alphabet set.
New character set: qwertyuiopasdfghjklzxcvbnm Input: "wwmm" Output: bbzy
Step 1: Given a new character set and input the string to make a relation. Step 2: and the original character set also given below. Step 3: Create a dictionary, we use here map technique, we map the English character set and new given character set, zip() does it for us. Both character sets are the map, here we match each character of given character set with each character of new charset sequentially. Step 4: iterate through the original string and get characters of an original character set. Step 5: join characters without space to get new string.
# Function to change string to a new character defnewString(cs,n): ori = 'abcdefghijklmnopqrstuvwxyz' newchar = dict(zip(cs,ori)) newstr = [newchar[chr] for chr in n] print (''.join(newstr)) # Driver program if __name__ == "__main__": newcharSet = 'qwertyuiopasdfghjklzxcvbnm' input = 'wwmn' newString(newcharSet,input)
- Python zip() Function
- Change MySQL default character set to UTF-8 in my.cnf?
- Python program to change character of a string using given index
- How to zip a folder recursively using Python?
- How to create a zip file using Python?
- How to zip a Python Dictionary and List together?
- How to set default parameter values to a function in Python?
- Python Program to Form a New String where the First Character and the Last Character have been Exchanged
- Java Program to replace all occurrences of a given character with new character
- How are files added to a zip file using Python?
- C# Program to change a character from a string
- How to change all the function arguments to lowercase in Python?
- How to create a zip archive of a directory using Python?
- How to Zip a directory in PHP?