def rot13b(text):
"""
A little smarter to use % to take care of the wrap-around
And do a check on the ord value, rather than looking in
string.ascii_lowercase
"""
# loop through the letters in teh input string
new_text = []
for c in text:
o = ord(c)
# do upper and lower case separately
if a <= o <= z:
o = a + ((o - a + 13) % 26)
elif A <= o <= Z:
o = A + ((o - A + 13) % 26)
new_text.append(chr(o))
return "".join(new_text)
# Translation table for 1 byte string objects:
# Faster if you build a translation table and use that
# build a translation table:
评论列表
文章目录