Caesar Cipher Download


The Caesar cipher is named after Julius Caesar, who used it to encrypt his secret communications. It’s a type of substitution cipher where every letter is shifted a fixed number of positions down the alphabet to produce the encrypted result.

Your challenge is to implement the Caesar cipher in Python! Fill in the code so that we can both encode and decode text. All code you need to edit is located in

You do not need to read or understand the contents of


For example, with a right shift of 3, the letter ‘a’ is replaced with ‘d’, ‘m’ is replaced with ‘p’, and so on.

If we encrypted the following message with a right shift of 4:

“Julius Caesar”

It would come out as:

“Nypmyw Geiwev”

Which looks like gibberish to the untrained eye. If you want to try some examples out yourself, here’s an online Caesar encoder/decoder.

Additional Details


Run the doctests to check your work by doing python3 -m doctest

Once you’ve passed all the tests, you can either call the functions yourself from the interpreter or run