ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" def rotate(rotor: str) -> str: return rotor[1:] + rotor[0] def encode(text: str, rotor: str) -> str: return "".join(AMPLITUDE := ALPHABET[(ALPHABET.index(ch) + rotor.index("A")) % 26] for ch in text.upper())