English · Dansk · Bahasa Melayu
Caesar Cipher
A beginner-friendly Caesar cipher encoder and decoder for the terminal.
What is it?
Day 8 of the Udemy course 100 Days of Code: The Complete Python Pro Bootcamp. The program shifts every letter of a message by a fixed number of places (with a shift of 3, E becomes H) and can also reverse the shift. It finds letter positions with list.index and wraps around the alphabet with the modulo operator.
What the exercise teaches
- Writing functions with parameters and return values
- Finding positions in a list and wrapping around with the modulo operator
- Using one function for both encoding and decoding
- Writing small automated tests
What it does
- Encode or decode as many messages as you like in one session
- Any shift, including negative shifts and shifts larger than 26
- Letter case is kept and characters that are not letters are left unchanged
- Input validation: a friendly message for an unknown direction or a shift that is not a whole number
Next