• + 0 comments
    def caesarCipher2(s, k):
        k = k % 26
        for i in s:
            if 97 <= ord(i) <= 122:
                res.append(chr(ind if (ind:=ord(i) + k) <= 122 else ind - 26))
            elif 65 <= ord(i) <= 90:
                res.append(chr(ind if (ind := ord(i) + k) <= 90 else ind - 26))
            else:
                res.append(i)