Zip function in Python to switch to a new character set

Python Methods and Functions


 New character set: qwertyuiopasdfghjklzxcvbnm Input: "utta" Output: geek Input: "egrt" Output: code 

We have a solution to this problem , see the link " link to character set . We'll solve this problem in python using the

# Function to change the line to a new character


def newString (charSet, input ):


# map of the original English character set

  # for a new character set

origCharSet = 'abcdefghijklmnopqrstuvwxyz'

mapChars = dict ( zip (charSet, origCharSet))


# iterate over the original line and get

# characters of the original character set

changeChars = [mapChars [ chr ] for chr in input


# join characters without spaces to get a new line

print ('' .join (changeChars))

# Driver program

if __ name__ = = "__ main__" :

charSet = 'qwertyuiopasdfghjklzxcvbnm'

  input = ' utta'

  newString (charSet, input )