Learn String Manipulation by Building a Cipher - Step 40

Tell us what’s happening:

learn string manipulation by building a cipher- step 40; I was asked to compare char with a space using the equality operator inside a for loop.

Your code so far


# User Editable Region

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

for char in text.lower():
    char == ''
    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

Hello and welcome to the forum :wave:

Please note

'' #empty string
' ' #space
5 Likes

Hello

okay, noted . Thank you

1 Like

I have implemented this correction but the code still didn’t pass

Can you please share your updated code?

You might have changed something else, you can try to reset the step and try again.

1 Like

okay, let me reset the step. Thank you.

Thank you, the code passed.

1 Like

Damn, This was the same error I was making…THanks so the implimentation becomes

removed

Please don’t post solution code the forum, thank you