curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/655261b2e1f2c197093f3993.md
Currently, spaces get encrypted as 'c'. To maintain the original spacing in the plain message, you'll require a conditional if statement. This is composed of the if keyword, a condition, and a colon :.
if x != 0:
print(x)
In the example above, the condition of the if statement is x != 0. The code print(x), inside the if statement body, runs only when the condition evaluates to True (in this example, meaning that x is different from zero).
At the top of your for loop, replace print(char == ' ') with an if statement. The condition of this if statement should evaluate to True if char is an empty space and False otherwise. Inside the if body, print the string 'space!'. Remember to indent this line.
You should not have print(char == ' ') in your code.
const commentless_code = __helpers.python.removeComments(code);
const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+in\s+text\.lower\s*\(\s*\)\s*/);
assert.notMatch(block_body, /print\s*\(\s*char\s*==\s*("|')\s\1\s*\)/);
You should replace print(char == ' ') with an if statement that triggers when char == ' '. Do not use parentheses to enclose the if condition and remember to include the final colon.
const commentless_code = __helpers.python.removeComments(code);
const {block_body} = __helpers.python.getBlock(commentless_code, /for\s+char\s+in\s+text\.lower\s*\(\s*\)\s*/);
assert(block_body.match(/if\s+char\s*==\s*("|')\s\1\s*:/));
You should print the string 'space!' inside your new if statement.
const commentless_code = __helpers.python.removeComments(code);
const {block_body} = __helpers.python.getBlock(commentless_code, /if\s+char\s*==\s*("|')\s\3\s*/);
assert(block_body.match(/print\s*\(\s*("|')space!\1\s*\)/));
Your code contains invalid syntax and/or invalid indentation.
({test: () => assert(true) })
--fcc-editable-region--
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)
--fcc-editable-region--