Learn String Manipulation by Building a Cipher - Step 36

Tell us what’s happening:

In the course Learn Manipulation, I’m stuck on step 36: At the moment, the encrypted character is updated in every iteration. It would be better to store the encrypted string in a new variable. Before your for loop, declare a variable called encrypted_text and assign an empty string (‘’) to this variable.

i added encrypted_text: ’ ’ on the line above my for loop, but it’s still not working. the for loop is correct

Your code so far


# User Editable Region

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

for char in text.lower():
    
    index = alphabet.find(char)
    new_index = index + shift
    new_char = alphabet[new_index]
    print('char:', char, 'new char:', new_char)

# 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/131.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 36

Welcome to the forum @zachp11

Before your for loop, declare a variable called encrypted_text and assign an empty string ('' ) to this variable.

I don’t see the new variable in the code you posted.

Happy coding

Tell us what’s happening:

I’m trying to perform the the following step in the learning string manipulation game, but it is not allowing me to proceed. Please see below for my code.
Step 36
At the moment, the encrypted character is updated in every iteration. It would be better to store the encrypted string in a new variable. Before your for loop, declare a variable called encrypted_text and assign an empty string (‘’) to this variable.

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
    new_char = alphabet[new_index]
    print('char:', char, 'new char:', new_char)

# 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/131.0.0.0 Safari/537.36

Challenge Information:

Learn String Manipulation by Building a Cipher - Step 36

You assign 4 variables in the first four lines here. They should all have the same format.

Please ensure you are assigning the new variable in the same way that you assigned the previous variables.

try this code.

  • removed by mod

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge. How to Help Someone with Their Code Using the Socratic Method

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

my apologies for revealing the answer. . … i will try to explain

you should try to play the variable
like a += b or b += a or a += c

declare a variable called encrypted_text and assign an empty string ('') to this variable

This is the only instruction. You don’t need to use += at all.

Closing this thread as it’s a month old and the OP has likely moved on.