curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/655a2a7210094920069b117c.md
Comparison operators allow you to compare two objects based on their values. You can use a comparison operator by placing it between the objects you want to compare.
They return a Boolean value — namely True or False — depending on the truthfulness of the expression.
Python has the following comparison operators:
<table> <thead> <tr> <th>Operator</th> <th>Meaning</th> </tr> </thead> <tbody> <tr> <td>==</td> <td>Equal</td> </tr> <tr> <td>!=</td> <td>Not equal</td> </tr> <tr> <td>></td> <td>Greater than</td> </tr> <tr> <td><</td> <td>Less than</td> </tr> <tr> <td>>=</td> <td>Greater than or equal to</td> </tr> <tr> <td><=</td> <td>Less than or equal to</td> </tr> </tbody> </table>At the beginning of your loop body, print the result of comparing char with a space (' '). Use the equality operator == for that.
You should compare char with a space using the equality operator inside your for loop.
({ test: () => {
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(/char\s*==\s*("|')\s\1/));
}
})
You should print the result of comparing char with a space inside your for loop.
({ test: () => {
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(/print\s*\(\s*char\s*==\s*("|')\s\1\s*\)/));
}
})
You should print the result of comparing char with a space at the beginning of your loop.
({ test: () => {
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(/^\s+print\s*\(\s*char\s*==\s*("|')\s\1\s*\)/));
}
})
--fcc-editable-region--
text = 'Hello World'
shift = 3
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in text.lower():
index = alphabet.find(char)
new_index = index + shift
encrypted_text += alphabet[new_index]
print('char:', char, 'encrypted text:', encrypted_text)
--fcc-editable-region--