Back to Freecodecamp

Step 13

curriculum/challenges/english/blocks/workshop-caesar-cipher/6818eb3f98c0bca5af7c8d03.md

latest793 B
Original Source

--description--

Now your code is reusable. However, the caesar function prints a message on the terminal and gives back None by default. To prove it, print encrypted_text at the end of your code.

--hints--

You should print encrypted_text outside of the function body.

js
({ test: () => assert(runPython(`_Node(_code).has_call("print(encrypted_text)")`)) })

--seed--

--seed-contents--

py
def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
    translation_table = str.maketrans(alphabet, shifted_alphabet)
    encrypted_text = text.translate(translation_table)
    print(encrypted_text)

encrypted_text = caesar('freeCodeCamp', 3)
--fcc-editable-region--

--fcc-editable-region--