CoreChallenge 9 of 34

Caesar cipher

Write caesar(text, shift) that shifts every letter by shift positions in the alphabet, wrapping around from z to a. Preserve case; leave spaces, digits and punctuation untouched.

Examples
caesar("Hello, World!", 3) → "Khoor, Zruog!"
caesar("Khoor", -3) → "Hello"
Exercise

Caesar cipher

4 checks
def caesar(text, shift):
    ...


print(caesar("Hello, World!", 3))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.