Caesar Cipher
Caesar Cipher
Write def caesar(text: str, shift: int) -> str that returns the text with every letter moved shift places along the alphabet, wrapping from z back round to a; upper-case letters stay upper case, lower-case stay lower case, and any other character (spaces, commas, digits) is copied unchanged. Use ord(ch) to get a character's code number and chr(code) to turn a code back into a character: work out the letter's position from 0 to 25 by subtracting the code of a (or A), add the shift, use the remainder operator % with 26 to wrap, then add the code of a (or A) back; this also handles a shift larger than 25 and a negative shift. Build the result one character at a time with for ch in text. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: two lines, the text then the shift as an integer, which the tests read and pass to your function before printing the text it returns.
Expected Output:
Khoor, Zruog= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...