Caesar Cipher
Medium · Strings
A Caesar cipher shifts every letter by a fixed number of places in the alphabet, wrapping around from z to a. ord(ch) gives a character code and chr(code) turns it back. The % operator handles the wrap, even for negative shifts: -1 % 26 is 25.
Write caesar(text, shift) that shifts the English letters a-z and A-Z by shift places and keeps their case. Leave every other character (spaces, digits, punctuation, accented letters) unchanged. shift can be negative or larger than 26.