Build a Caesar Cipher - Step 25

Tell us what’s happening:

there is no spelling error this time. but i got
You should assign Pbhentr vf sbhaq va hayvxryl cynprf. to encrypted_text.

Your code so far

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())
    encrypted_text = text.translate(translation_table)
    return encrypted_text

def encrypt(text, shift):
    return caesar(text, shift)
    
def decrypt(text, shift):
    return caesar(text, shift, encrypt=False)

# User Editable Region


encrypted_text = decrypt('Pbhentr vf sbhaq va hayvxryl cynprf.',13)
print(encrypted_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 OPR/127.0.0.0

Challenge Information:

Build a Caesar Cipher - Step 25

Hi there,

Please read again what the value of encrypted_text should be. It also says to define a variable decrypted_text, but I don’t see that in your code.

Happy coding!

1 Like

I see a function call, not a string assigned to encrypted_text

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.