Build a Caesar Cipher - Step 10

Tell us what’s happening:

Can someone please tell me what the problem with my code is

Your code so far


# User Editable Region

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

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36

Challenge Information:

Build a Caesar Cipher - Step 10

You have changed the starting code for this step. Please reset this step to restore the given code and try again. This time, only add code to put the given code inside a function. Don’t change anything else.

image

1 Like

Thank you! It worked <3