Build a Caesar Cipher - Step 10

Tell us what’s happening:

I am on step 10 of build a caesar cipher using python. The instructions say to 'move all the code I have written so far within the caesar function body’. I have tried writing

def caesar():
alphabet
shift
shifted_alphabet
translation_table

But something is missing - could it be some kind of command that connects the variables together? Or a command in the ‘def caesar():’ heading?

Your code so far


# User Editable Region

alphabet = 'abcdefghijklmnopqrstuvwxyz'
shift = 5
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
translation_table = str.maketrans(alphabet, shifted_alphabet)
text = 'hello world'
encrypted_text = text.translate(translation_table)
print(encrypted_text)
def caesar():
    (alphabet)
    (shift)
    (shifted_alphabet)
    (translation_table)

# 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 10

Hi. It says to put all your existing code within the new function. Have you done this?

I thought I had done this by copying and pasting all the code below the ‘def caesar():’ function. This is clearly not right?

Like this:

def caesar():


alphabet = 'abcdefghijklmnopqrstuvwxyz'
shift = 5
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
translation_table = str.maketrans(alphabet, shifted_alphabet)

I’m not sure what ‘within’ the new function means?

Have I missed some parameters or something?

These lines are outside of your function but shouldn’t be.

These lines are inside of your function but aren’t lines you were asked to write.

Ok thanks JeremyLT I’ve managed to work it out!!