Learn String Manipulation by Building a Cipher - Step 37

Tell us what’s happening:

The question is telling me to replace new_char with encrypted_text. also modify the print() call into print(‘char:’, char, ‘encrypted text:’, encrypted_text) to reflect this change. I believe I have done that, but it’s telling me my code does not pass.I am very confused Could you point out my mistake

Your code so far


# User Editable Region

text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
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

Hi there, welcome to the community!

Your code is correct but has one extra and one missing element (special character). The lesson asked:

Now, replace new_char with encrypted_text. Also, modify the print() call into print('char:', char, 'encrypted text:', encrypted_text) to reflect this change.

Now review your code and fix the extra word.

1 Like

Thank you, but the thing is i copied your code but it is still giving the same error.
You should turn your print() call into print('char:', char, 'encrypted text:', encrypted_text) inside your for loop.

I think you may have copied your own code, which was quoted.

Read the rest of the reply, no one is going to give you the solution to copy and paste.

I finally found where i was wrong i was printing print(“encrypted_text” = encrypted text ), instead of removed by mod

Glad you got it :+1: Please do not post solution code to the forum