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
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
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.