Created
June 25, 2020 13:04
-
-
Save Zomatree/f3ad9f9ae081a146a2ad6a5d00b1950a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
class CyclicList(list): | |
def __getitem__(self, x): | |
index = x.__index__() | |
return super().__getitem__(index % len(self)) | |
l = CyclicList(string.ascii_lowercase+string.punctuation+string.whitespace) | |
inp = input("Enter text: ").lower() | |
if not all(char for char in inp if char in l): | |
raise TypeError("Not all letters") | |
shift = int(input("Enter amount to shift by: ")) | |
print("".join(map(lambda char: l[l.index(char)+shift], inp))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment