
Checkpoint
Checkpoint: The Harbor Signal
A ship is waiting outside Lantern Harbor. The harbor master wants to flash a secret message to the captain, and the captain must be able to read it back.
To decode, you just shift the other way. If the message was encoded with key 5, decoding shifts by -5.
This checkpoint uses the whole chapter: ord/chr, wrapping with
%, and keeping capitals, spaces and punctuation.
Assignment
shift_char(ch, shift)shifts one character. Lowercase stays lowercase, capitals stay capitals, anything else is unchanged.encode(message, shift)returns the whole message shifted.decode(message, shift)turns an encoded message back. It should reuseencode(orshift_char) with a negative shift.- Print
encode("Ship at Harbor 9!", 5), then print the decoded version on the next line.
shift_char(ch, shift)shifts one character. Lowercase stays lowercase, capitals stay capitals, anything else is unchanged.encode(message, shift)returns the whole message shifted.decode(message, shift)turns an encoded message back. It should reuseencode(orshift_char) with a negative shift.- Print
encode("Ship at Harbor 9!", 5), then print the decoded version on the next line.
main.py Python sleeping
Press Run to try your code, then Check to test it.