# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index], char
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/605.1.15 (KHTML, like Gecko) Version/16.0 Safari/605.1.15
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 43
the instruction is Now, instead of printing 'space!' , use the addition assignment operator to add the space (currently stored in char ) to the current value of encrypted_text .
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
he instruction is Now, instead of printing 'space!' , use the addition assignment operator to add the space (currently stored in char ) to the current value of encrypted_text .
for char in text.lower():
if char == ’ ':
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)
You should use the += operator to add char to the current value of encrypted_text inside your new if statement.
I tried. I don’t know what is wrong. Honestly this is my first day here. Prior I finished just Mimo app in a week so I have zero qualification so far I’m just interested
Now, instead of printing 'space!' , use the addition assignment operator to add the space (currently stored in char ) to the current value of encrypted_text .
for char in text.lower():
if char += encrypted_text:
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)
If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.
The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.