/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#1 import string frm = "abcdefghijklmnopqrstuvwxyz" to = "cdefghijklmnopqrstuvwxyzab" data = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylbgq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.""" print string.translate(data, string.maketrans(frm,to)) #2 import string frm = "abcdefghijklmnopqrstuvwxyz" to = "cdefghijklmnopqrstuvwxyzab" data = """g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylbgq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.""" result = '' for c in data: if c in frm: result += to[frm.index(c)] else: result += c print result #3 import string s = " " for c in t : if c in string.letters : s += chr((ord(c) + 2 - 97) % 26 + 97) else : s += c print s </code>
URL: http://www.pythonchallenge.com/