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.
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
Post a Comment