Tell us what’s happening:
I tried a lot but I didn’t know where I went wrong 
Your code so far
# User Editable Region
text = "Hello World"
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ""
for char in text.lower():
if char == ' ':
encrypted_text += ' '
else:
index = alphabet.find(char)
new_index = (index + shift) % len(alphabet)
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/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 40
@DoniaAli1011, look carefully at the second line of your if statement.
1 Like
Reset, read the instructions and try it again.
Here is the instruction:
At the beginning of your loop body, print the result of comparing char
with a space (' '
). Use the equality operator ==
for that.
You should be adding 1 line to the code, and it should print
something.
1 Like
A space needs to be added in ‘’, which is the comparison between char and ‘Space’
1 Like
Please make sure you are familiar with the instructions of the step before giving advice, thanks!
Thank you very much for your help I have solved it successfully and skipped this step
Thank you very much for your help I have solved it successfully and skipped this step.
1 Like
Thank you very much for your help I have solved it successfully and skipped this step .
Thank you very much for your help I have solved it successfully and skipped this step
.