At the beginning of your loop body, print the result of comparing char with a space (' ' ). Use the equality operator == for that.
I’ve tried about 5 different ideas for the same line in <>
*Also …Am I using <> Right in the example to help you look for the code I need help on?
Your code so far
# User Editable Region
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
` print (char == (' '))` #huh? how come i get those ` ` instead of <>?
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
If you want to show us code, it should be enclosed within two sets of triple backticks so that it displays correctly on the forum.
You can do this manually or use the Preformatted Text tool (</> icon or CTRL+e) to create the backticks for you.
If you want to point out a particular section/line of your code which you need help with, it’s best to use the usual commenting syntax, rather than adding any stray characters or other artifacts.
Hello! I am having the same issue with this line, except it will not accept
for char in text.lower():
print(char == (’ ')) << Line that should be implemented?
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print(‘char:’, char, ‘encrypted text:’, encrypted_text)
Can you please explain what I am doing wrong?