Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

I am not able to get past this step. I have tried many different ways, I have read the other forums regarding this step and nothing seems to work.

Your code so far


# User Editable Region

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

# User Editable Region

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Mod edit: solution removed

Hi there.

At that point in the code, char has not been declared yet. It’s declared right when the loop starts. You want to move that line near the top of the loop, but not outside of it.

I hope this makes sense.