Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

no matter what i try, it won’t accept the line
print(char == ’ ')

any tips? i feel like i’ve done everything but i clearly haven’t lol
it keeps giving me:

Your code raised an error before any tests could run. Please fix it and try again.

i’ve reset twice to no luck

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 37

Hi there and welcome to our community!

At the top of your loop, print the result of comparing char with an empty space.

Your code is correct but is in the wrong place.
‘At the top of your loop’ means inside the loop, not above it.

You cannot use a variable ( in your case char) before its declaration (which occurs within the loop). Therefore you got an error. Follow the previous suggestion and your code will pass.