Learn String Manipulation by Building a Cipher - Step 49

Tell us what’s happening:

The task says: “Right after your shift variable, declare a function called caesar and indent all the following lines to give your new function a body.”

The console error is “You should indent all the lines after shift = 3 so that they become your new function body.”
However, if I indent the function def(caesar) it returns an error too.
I’m not sure what is missing in my code, thank you.

Your code so far


# User Editable Region

text = 'Hello Zaira'
shift = 3

def caesar():
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    encrypted_message = ''
    for char in message.lower():
        if char == ' ':
            encrypted_message += char
        else:
            index = alphabet.find(char)
            new_index = (index + shift) % len(alphabet)
            encrypted_message += alphabet[new_index]
    print('plain message:', message)
    print('encrypted message:', encrypted_message)


# 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/125.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 49

you changed the code, you should only indent it

like, it should be encrypted_text = '' but you have encrypted_message = ''

reset the step, try again without making changes other than indenting

1 Like