You are viewing a single comment's thread. Return to all comments →
def caesarCipher(s, k): # Write your code here k %= 26 cyphStr = "" lAlph = "abcdefghijklmnopqrstuvwxyz" uAlph = lAlph.upper()
lAlph = lAlph[k:] + lAlph[:k] uAlph = uAlph[k:] + uAlph[:k] for c in s: if 'a' <= c <= 'z': charASCII = (ord(c) - ord('a'))%26 cyphStr += lAlph[charASCII] elif 'A' <= c <= 'Z': charASCII = (ord(c) - ord('A'))%26 cyphStr += uAlph[charASCII] else: cyphStr += c return cyphStr
Seems like cookies are disabled on this browser, please enable them to open this website
Caesar Cipher
You are viewing a single comment's thread. Return to all comments →
def caesarCipher(s, k): # Write your code here k %= 26 cyphStr = "" lAlph = "abcdefghijklmnopqrstuvwxyz" uAlph = lAlph.upper()