Build a Caesar Cipher - Step 10

Tell us what’s happening:

def caesar():
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)

I have attempted this manually and copy/paste several times, even refreshed the page and worked from step 9. I have done the cipher in the old python, this won’t work for some reason.

Your code so far


# User Editable Region

def caesar():
    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)


# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 10

when you start the step there are 7 lines of code, now there are only 6 lines of code inside the function, you should reset the step (with the riound arrow🔄️ button) and then try again, do not delete any lines, move them all inside the function

You’ve posted two versions of your code. The last line is different

Thank you all for your help! I got it figured out :slight_smile:

1 Like