Build a Caesar Cipher step 23

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, False)

encrypted_text = caesar('freeCodeCamp', 3)

print(encrypted_text)

im getting this error: You should have a function named encrypt with two parameters, text and shift.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

or at least please provide a link to the challenge

I’ve edited your post to improve the readability of the code. When you enter a code block into a forum post, please precede it with three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add the backticks.

Pre-formatted-text

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

1 Like

You have created the new functions inside the caesar function. This is an indentation issue.

1 Like

you’re right, thank you.