rot13 in Python 3.x
As of Python 3.0, rot13 is no longer built accessible from the str.encode("rot13") call. If needed, here is an implementation I pieced together:
from string import ascii_uppercase, ascii_lowercase def rot13(data): """ A simple rot-13 encoder since `str.encode('rot13')` was removed from Python as of version 3.0. It rotates both uppercase and lowercase letters individually. """ total = [] for char in data: if char in ascii_uppercase: index = (ascii_uppercase.find(char) + 13) % 26 total.append(ascii_uppercase[index]) elif char in ascii_lowercase: index = (ascii_lowercase.find(char) + 13) % 26 total.append(ascii_lowercase[index]) else: total.append(char) return "".join(total)
Pretty simple, right? Knowing how modulus (%) works helped greatly in finding the proper index. I hope this helps.
Update: There's a simpler solution on the comments below. You should probably use it instead.

James Bennett wrote,
Simpler and probably more efficient:
Zack C wrote,
@James
My knee jerk reaction was to want to use string.ascii_uppercase/lowercase, but it doesn't beat yours in terms of brevity or clarity.
iDontGiveMyNameToRandomSitesOnTheInternet wrote,
The simplest way to do this would probably be: