Write a python function for Caesar Cipher, with given shift value and return the modified text


Topic: Write a python function for Caesar Cipher, with given shift value and return the modified text

Solution

def caesar_cipher(text, shift=1):
    alphabet = string.ascii_lowercase
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    table = str.maketrans(alphabet, shifted_alphabet)
    return text.translate(table)



List all Python Programs