Back to Freecodecamp

Step 58

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/655491bd5b98b813fa5bedca.md

latest981 B
Original Source

--description--

Now modify your function declaration: change the function name into vigenere and the second parameter into key.

--hints--

You should modify your function name into vigenere.

js
assert.match(code, /^def\s+vigenere\s*\(.*\)\s*:/m)

Your vigenere function should take message and key as the parameters.

js
assert.match(code, /^def\s+vigenere\s*\(\s*message\s*,\s*key\s*\)\s*:/m)

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello Zaira'
shift = 3

def caesar(message, offset):
    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--