curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/65549561463f0016876e852c.md
Since your key is shorter than the text that you will have to encrypt, you will need to repeat it to generate the whole encrypted text.
At the beginning of your function body, declare a key_index variable and set it to zero.
You should declare a variable called key_index at the beginning of your function body.
const commentless_code = __helpers.python.removeComments(code);
const {function_body} = __helpers.python.getDef(commentless_code, "vigenere");
assert(function_body.match(/^\s*key_index\s*=/));
You should assign 0 to your key_index variable.
const commentless_code = __helpers.python.removeComments(code);
const {function_body} = __helpers.python.getDef(commentless_code, "vigenere");
assert(function_body.match(/key_index\s*=\s*0/));
Your code contains invalid syntax and/or invalid indentation.
({test: () => assert(true) })
--fcc-editable-region--
text = 'Hello Zaira'
custom_key = 'python'
def vigenere(message, key):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
encrypted_text = ''
for char in message.lower():
if char == ' ':
encrypted_text += char
else:
index = alphabet.find(char)
new_index = (index + offset) % len(alphabet)
encrypted_text += alphabet[new_index]
print('plain text:', message)
print('encrypted text:', encrypted_text)
--fcc-editable-region--