Build a Caesar Cipher - Step 25

Tell us what’s happening:

I don’t understand where I’m going wrong.
It tells me the error is that I’m not assigning the value to encrypted_text.

And the instructions say to replace the value, but I don’t see that variable present before in that function.

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)
    

# User Editable Region

def decrypt(text, shift):
    encrypted_text = 'Pbhentr vf sbhaq va hayvxryl cynprf.'
    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/141.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 25

Welcome to the forum @anlufevi

It looks like you place the variables in a function.

Please reset the step to restore the seed code.

Then add the variables without indenting them.

Happy coding

1 Like

Thanks, small detail I did not catch.

1 Like