Tell us what’s happening:
I have tried the Read-Search-Ask method and searched for similar questions already answered. My code seems logically correct, but it’s not passing Step 37 where I’m asked to replace new_char with encrypted_text. I’ve removed any use of new_char, updated the print statement to show encrypted_text, yet the test still fails. I’m seeking help understanding what specific structure or syntax the test expects.
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)
if index != -1:
new_index = (index + shift) % len(alphabet)
encrypted_text += alphabet[new_index]
else:
encrypted_text += char
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/138.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 37