Build a Caesar Cipher - Step 10

Tell us what’s happening:

Not sure what I am doing wrong. Any guidance would help.

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 = '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)
    print('caesar')

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/26.2 Safari/605.1.15

Challenge Information:

Build a Caesar Cipher - Step 10

Welcome to the forum @morrisbrittany37

You have a double up in code. Try removing the code not defined by a function.

Happy coding

1 Like

Thank you. I reset the step and I was putting an extra line that was not necessary.

1 Like