Created
November 22, 2018 14:33
-
-
Save duhaime/9d3ef5b0a2751e9592b61fe4eda899fe to your computer and use it in GitHub Desktop.
rotate n
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
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