Well i am not sure what i am doing wrong… i checked the posts and tehr was nothing heplful and searched on youtube too but still no help.
i would someone to tell me whats wrong in this and help me as i am unable to figure it out from quite some time
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
if char == ' ':
print('True')
else:
print('False')
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/121.0.0.0 Safari/537.36
Challenge Information:
Learn String Manipulation by Building a Cipher - Step 41
This is what I have, and it still DOESNT work . I already spent an hour on . the spaces are there as well. They should have an answer guide, to help figure out the problem.
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
print(char =='')
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
ou should compare char with a space using the equality operator inside your for loop. You should print the result of comparing char with a space inside your for loop. You should print the result of comparing char with a space at the beginning of your loop. // tests completed
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.