Learn String Manipulation by Building a Cipher - Step 43

Tell us what’s happening:

It marks me this:
3. Your code has an indentation error. You may need to add pass on a new line to form a valid block of code.
I DO NOT KNOW WHAT AN INDENTATION IS. PLEASE EXPLAIN!!!

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
        if char == ' ':
       encrypted_text += char
        else:
        index = alphabet.find(char)
        new_index = index + shift
        encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)

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

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 43

Welcome to the forum @70N10_JC

Here is a comparison of the original code and your code.

The code in blue is the original code, the code in red is your code.
The code in magenta is the overlap.

Indentation is the whitespace (created using the space bar on your keyword) that gives structure to Python code.

It looks like you indented every line after the for loop.

After a colon, Python expects the next line to start with four additional lines compared to the line above ending in a colon. Those lines which are indented by four additional spaces are considered part of that code block.

Please reset the step to restore the seed code.

Then place the else statement so that it matches the indentation of the if statement.

The code to execute for the else needs indenting.

Happy coding