Python: Make a string translater that translate a string according to given mapping

Hi friends,

Below is the script to translate a string according to given mapping:

from string import maketrans
intab ="abcdefghijklmnopqrstuvwxyz"
outtab="cdefghijklmnopqrstuvwxyzab"
trantab = maketrans(intab, outtab)
a = raw_input('Enter string to translate... ')
b=a.translate(trantab);
print b


===================================================================

Explanation:

1. Replace a with c, b with d and so on.
2. Remember, the length of intab and outtab must be same.

Comments