Python strings have a translate
method that applies a substitution cipher. There is also a function str.maketrans
(string.maketrans
in Python 2) that helps with building the translation table:
>>> from string import ascii_lowercase as alphabet
>>> shift = 13
>>> cipher = str.maketrans(alphabet, alphabet[shift:] + alphabet[:shift])
>>> print("caeser salad is tasty".translate(cipher))
pnrfre fnynq vf gnfgl
of coarse in python2(with a shift of 13) one can simply do "My Message".encode("rot13")