Learn String Manipulation by Building a Cipher - Step 44

Tell us what’s happening:

I keep getting an error that says " You should indent the lines of code after your else clause except the print() call."

The Directions: As you can see in your output, when the loop iterations reach the space, a space is added to the encrypted string. Then the code outside the if block executes and a c is added to the encrypted string.

To fix it, add an else clause after encrypted_text += char and indent all the subsequent lines of code except the print() call.

I have indent my else statement, I cannot figure out what I am missing. I know I’m doing something wrong i just need a better hint as to what I’m doing wrong.

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
        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 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 44

Welcome to the forum @S.Wall

Please delete the white space after the else: statement.

Happy coding


That worked. I didn’t even realize I had put white space there. Thank you!

1 Like