Build a Caesar Cipher - Step 23

Tell us what’s happening:

i can not solve the step 23 of build a caesar cipher, can anyone help me with this please? thank you!

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

# User Editable Region

    encrypt(text,shift)
        return "caesar(text,shift)."

    decrypt(text, shift)
        return "caesar(text,shift,false)."

# User Editable Region


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

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

Challenge Information:

Build a Caesar Cipher - Step 23

Do you remember how to declare a function? Look at how you defined the caesar() function.

As well, you don’t want to define these functions within the caesar() function.

almost there,

try
removed

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

I created the encrypt and decrypt functions, but it keeps saying that I should return the caesar function which I did. In all honesty, I have survived the caesar cipher challenge by figuring things out as I go, just like everyone else, but somehow I cannot visualize what the language is saying per line of code.

Please open a new thread

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. This button only appears if you have tried to submit an answer at least three times.

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.