Learn String Manipulation by Building a Cipher - Step 42

Tell us what’s happening:

What wrong did I do here, I have added the operator

Your code so far


# User Editable Region

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

for char in text.lower():
    if char += ' ':
       
    index = alphabet.find(char)
    new_index = index + shift
    encrypted_text += char 
    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/126.0.0.0 Safari/537.36 Edg/126.0.0.0

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 42

Where is the following code line given by default?

encrypted_text += alphabet[new_index]

Reset step

This line should be found within the ‘if’ statement (don’t forget to indent it).

1 Like

while doing at first It showed me I should give char as value to the current encrypted_text, but now I realised and corrected It, thanks

1 Like