Build a Caesar Cipher - Step 22

Tell us what’s happening:

I am doing as recommended in the step 22
if not encrypt:
shift =-shift
Even then check your code reports you should set shift to -shift when encrypt is not truthy

Your code so far

def caesar(text, shift, encrypt=True):
    
    if not encrypt: 
        shift =-shift

    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'
    

# User Editable Region

    

# User Editable Region

    
    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


encrypted_text = caesar('freeCodeCamp', 3)
print(encrypted_text)

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 22

Hi @fccf62ff6b8 and welcome to our community!

Your code is correct but is in the wrong place. It should be below the other conditional statements (inside the User Editable Region).