Learn String Manipulation by Building a Cipher - Step 40

Tell us what’s happening:

on line 7
i have tried everything but i can’t figure it out
i am supposed to do, Print ( char == ’ ’ )
but its not working , thoughts ?

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''

for char in text.lower():
    print (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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 40

First problem is your print() statement. Look at the other print statement for an example of how to do this. Basically, you cannot have a space between print and the (brackets) and this goes for calling every function,. It will always be like this:

function()
print("this", that)

Next, note the difference here:

'' #empty string
' ' #space character

I figured it out
i needed to put a space between my ’ ’ like ’ ’ , which is wierd because is was reurning false even though there was no space.

It was returning false because it was never equal to an empty string. It was either a letter or a space.