Skip to content

Instantly share code, notes, and snippets.

@duhaime
Created November 22, 2018 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duhaime/9d3ef5b0a2751e9592b61fe4eda899fe to your computer and use it in GitHub Desktop.
Save duhaime/9d3ef5b0a2751e9592b61fe4eda899fe to your computer and use it in GitHub Desktop.
rotate n
def rotn(s, n=13, f=97, l=122):
'''Rotate each char in `s` with codepoint between `f` and `l` by `n`'''
return ''.join([chr(((ord(c)-f+n) % (l-f+1))+f) if f<=ord(c)<=l else c for c in s.lower()])
a = rotn('I believe in a thing called love')
b = rotn(a)
print(a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment