Back to Freecodecamp

Step 15

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

latest1.1 KB
Original Source

--description--

You might have noticed that, although the message is encrypted, the uppercase characters have been left untouched. This happens because the translation table does not include uppercase letters.

To fix it, you'll need to modify the strings passed to your str.maketrans() call using the upper() method:

py
greet = "Hello"
print(greet.upper()) # HELLO

Update your str.maketrans() call by concatenating to each argument the uppercase version of the argument itself.

--hints--

You should modify the arguments of your str.maketrans() call by concatenating to each argument the uppercase version of the argument itself.

js
({ test: () => assert(runPython(`caesar('This Is A TEST', 5) == 'Ymnx Nx F YJXY'`)) })

--seed--

--seed-contents--

py
def caesar(text, shift):
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    shifted_alphabet = alphabet[shift:] + alphabet[:shift]
--fcc-editable-region--
    translation_table = str.maketrans(alphabet, shifted_alphabet)
--fcc-editable-region--
    return text.translate(translation_table)

encrypted_text = caesar('freeCodeCamp', 3)
print(encrypted_text)