Tell us what’s happening:
Hi! i have been struggling with this code and i do not know why it is wrong or how i should fix it.
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char != ' ':
print('space!')
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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 42
in your first if statement you should write
–removed–
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.
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.
The condition of this if
statement should evaluate to True
if char
is an empty space
If char
is equal to an empty space, will your condition evaluate to True
?
Warm Welcome, there !!
It seems that you wrote != operator for the if condition, meaning there should NOT be a space there. Change like this :
Mod Edit SOLUTION REMOVED
Thanking You !!
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.
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.
Ok. For Sure. I will do the same now onwards, @JeremyLT
Hey! I still don’t get the code, may you please write the right code please
It seems I’ll be stuck in this step