Created
May 1, 2012 10:12
-
-
Save bentappin/2567007 to your computer and use it in GitHub Desktop.
Caesar shift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
def caesar_shift(s, shift): | |
t = string.maketrans( | |
string.lowercase + string.uppercase, | |
string.lowercase[shift:] + string.lowercase[:shift] + string.uppercase[shift:] + string.uppercase[:shift] | |
) | |
return s.translate(t) | |
def rot_13(s): | |
return caesar_shift(s, 13) | |
hi = 'Uryyb, Jbeyq!' | |
print rot_13(hi) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment