Skip to content

Strings · stretch

Caesar cipher

Write caesar(text, shift) moving every lowercase letter shift places along the alphabet, wrapping from z back to a. Everything else stays as it is. caesar("abz", 1) is "bca".

ord("a") is 97 and chr(97) is "a": letters are numbers underneath.

Run adds print(caesar("hello, world", 3)) after your code, to try it.

Stuck on the idea rather than the code? The String methods lesson walks through it.