Back to Freecodecamp

Step 59

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/6554930320d70414e7b6acc6.md

latest1.1 KB
Original Source

--description--

Delete your shift variable. Then, declare a new variable called custom_key and assign the value of the string 'python' to this variable.

--hints--

You should delete the shift variable and its value.

js
({ test: () => assert.isFalse(__userGlobals.has("shift")) })

You should declare a variable called custom_key.

js
({ test: () => assert(__userGlobals.has("custom_key")) })

You should assign the string 'python' to your custom_key variable.

js
({ test: () => assert.equal(__userGlobals.get("custom_key"), "python") })

--seed--

--seed-contents--

py
--fcc-editable-region--
text = 'Hello Zaira'
shift = 3
--fcc-editable-region--
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)