You are viewing a single comment's thread. Return to all comments →
def caesarCipher(s, k): res = "" for i in s: if ord(i) >= ord('A') and ord(i) <= ord('Z'): asciiValue = ord(i) + k % 26 if asciiValue > ord('Z'): asciiValue = ord('A') - 1 + asciiValue % ord('Z') res += chr(asciiValue) elif ord(i) >= ord('a') and ord(i) <= ord('z'): asciiValue = ord(i) + k % 26 if asciiValue > ord('z'): asciiValue = ord('a') - 1 + asciiValue % ord('z') res += chr(asciiValue) else: res += i return res
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 →