Tell us what’s happening:
im unable to sort out this one been tried many times
Your code so far
# User Editable Region
def caesar(text, shift, encrypt=True):
if not isinstance(shift, int):
return 'Shift must be an integer value.'
if shift < 1 or shift > 25:
return 'Shift must be an integer between 1 and 25.'
alphabet = 'abcdefghijklmnopqrstuvwxyz'
if not encrypt:
shift = -shift
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
translation_table = str.maketrans(alphabet + alphabet.upper(), shifted_alphabet + shifted_alphabet.upper())
return text.translate(translation_table)
def encrypt(text, shift):
return caesar(text, shift)
def decrypt(text, shift):
return caesar(text, shift, False)
encrypted_text = 'Pbhentr vf sbhaq va hayvxryl cynprf'
print(encrypted_text)
decrypted_text = decrypt(encrypted_text, 13)
print(decrypted_text)
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Build a Caesar Cipher - Step 25