You are viewing a single comment's thread. Return to all comments →
Python:
def caesarCipher(s, k): alphabets = 'abcdefghijklmnopqrstuvwxyz' encrypted_str = "" for i in range(len(s)): char = s[i] if char.isalpha(): next_idx = alphabets.index(char.lower()) + k next_letter = alphabets[next_idx % 26] encrypted_str += next_letter.upper() if char.isupper() else next_letter else: encrypted_str += char return encrypted_str
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 →
Python: