You are viewing a single comment's thread. Return to all comments →
Here's an option that does not rely on ASCII positioning.
abc = "abcdefghijklmnopqrstuvwxyz" pos = {c: i for i, c in enumerate(abc)} ciphered = [] for c in s: cl = c.lower() if cl in abc: new_ind = (pos[cl] + k) % 26 cipher_letter = abc[new_ind] if c.islower() else abc[new_ind].upper() ciphered.append(cipher_letter) else: ciphered.append(c) print("".join(ciphered))
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 →
Here's an option that does not rely on ASCII positioning.