Learn String Manipulation by Building a Cipher - Step 34

Tell us what’s happening:

Describe your issue in detail here.

Step 34

Now, replace new_char with encrypted_text. Also, modify the print() call to reflect this change.

The error is:
You should replace new_char with encrypted_text .

I don’t know what more can be done to replace ‘new_char’ with encrypted_text

Your code so far

text = ‘Hello World’
shift = 3
alphabet = ‘abcdefghijklmnopqrstuvwxyz’
encrypted_text = ‘’

for char in text.lower():
index = alphabet.find(char)
new_index = (index + shift)
# new_char = alphabet[new_index]
# encrypted_text += new_char
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted_text:’,encrypted_text)


# 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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 34

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

remove this _ underscore here

Welcome to our community!

String 'encrypted_text:' goes without an underscore between the words.

I removed and tried and meet the same error.

ecrypted_text is equal to the alphabet[new_index] (don’t use +=, only =).

remove this _ underscore h

why do you remove it im confused

There’s two things here, a string which is just text describing what’s being printed

‘encrypted_text:’

and the variable being printed:

encrypted_text

The variable has an underscore because you can’t have spaces in a variable and it’s two words, it just makes it easier to read. You also have to reference a variable by it’s exact name, you can’t change it.

The text could be anything you want, and we don’t usually_write_spaces_as_underscores

‘This is the variable named “encrypted_text”:’

‘Encrypted Message:’

You might write something like that to describe it. If you wanted you could write encrypted_text as well, if you wanted, just not for this test. It’s a bit arbitrary.