Sunday, 23 October 2011


I know

Not a smart way but i did
import string
for i in range(len(oStr)):
for a in range(len(string.ascii_lowercase)):
if a<=23:
if oStr[i:i+1] == string.ascii_lowercase[a]:
oNewStr = oNewStr[:i]+string.ascii_lowercase[a+2]+oStr[i+1:]
if oStr[i:i+1] == string.ascii_lowercase[a]:
oNewStr = oNewStr[:i]+string.ascii_lowercase[a-24]+oStr[i+1:]

"i hope you didnt translate it by hand. thats what computers are for. doing it in by hand is inefficient and that's why this text is so long. using string.maketrans() is recommended. now apply on the url."

here is the way to using string.maketrans()
follow the example, and here is my code.
text="g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj."
intab = "abcdefghijklmnopqrstuvwxyz" #string.ascii_lowercase,
outtab = "cdefghijklmnopqrstuvwxyzab"#string.ascii_lowercase[2:]+string.ascii_lowercase[:2]
from string import maketrans
trantab = maketrans(intab, outtab)#
print text.translate(trantab);

No comments: