learn-string-manipulation-by-building-a-Cypher-Step 50

  text = 'Hello Zaira'
shift = 3
    def caesar():
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
    if char == ' ':
        encrypted_text += char
        index = alphabet.find(char)
        new_index = (index + shift) % len(alphabet)
        encrypted_text += alphabet[new_index]
print('plain text:', text)
print('encrypted text:', encrypted_text)

the error message says
Sorry, your code does not pass. Try again.

You should use the def keyword to declare a new function.

what am I doing wrong here?

Hi there. It seems your code formatting was messed up due to being outside of a code block. Can you please edit your post and re-copy your code inside of a code block. You can do this by wrapping the text with three grave symbols like below.

My code

P.S Please use the “Ask for help” button in challenges rather than directly creating new posts directly.

I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

Have a close look at your indentation

indent all the following lines to give your new function a body.

The format for a function should look like this:


def function():