Change string to a new character set | function for converting the string ; find the index of each element of the string in the modified set of alphabets replace the element with the one having the same index in the actual set of alphabets ; Driver Code
def conversion ( charSet , str1 ) : NEW_LINE INDENT s2 = " " NEW_LINE for i in str1 : NEW_LINE INDENT s2 += alphabets [ charSet . index ( i ) ] NEW_LINE DEDENT return s2 NEW_LINE DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT alphabets = " abcdefghijklmnopqrstuvwxyz " NEW_LINE charSet = " qwertyuiopasdfghjklzxcvbnm " NEW_LINE str1 = " egrt " NEW_LINE print ( conversion ( charSet , str1 ) ) NEW_LINE DEDENT