Build a Caesar Cipher - Step 25

Tell us what’s happening:

Can anybody guide me? I’ve done everything the instructions said to do and even the code runs smoothly in the terminal.

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'
    encrypted_text = 'Pbhentr vf sbhaq va hayvxryl cynprf.'
    decrypted_text=(encrypted_text,13)

    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 = encrypt('freeCodeCamp', 3)
print(encrypted_text)
decrypted_text = decrypt('Pbhentr vf sbhaq va hayvxryl cynprf.', 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/153.0.0.0 Safari/537.36 Edg/153.0.0.0

Challenge Information:

Build a Caesar Cipher - Step 25

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-caesar-cipher/681a44f4c3235f7d8f428545.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @Madhuri_Suthar,

Did you do this?

Replace the value assigned to encrypted_text with the following string, which represents a message to decrypt: Pbhentr vf sbhaq va hayvxryl cynprf.

Or this?

…declare a variable named decrypted_text and assign it a call to decrypt with encrypted_text as it first argument and a shift of 13 as the second argument.

Happy coding