Back to Freecodecamp

Step 56

curriculum/challenges/english/blocks/learn-string-manipulation-by-building-a-cipher/6553f6086add4b2cbb99fd78.md

latest1.1 KB
Original Source

--description--

At the bottom of your code, after your existing caesar(text, shift) call, call your function again.

This time, pass the text variable and the integer 13 as arguments.

--hints--

You should call your function again, this time passing text and 13 as arguments.

js
({ test: () => assert.match(code, /^caesar\s*\(\s*text\s*,\s*13\s*\)/m) })

You should keep the existing function call.

js
({ test: () => assert.match(code, /^caesar\s*\(\s*text\s*,\s*shift\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)

caesar(text, shift)
--fcc-editable-region--