
Checkpoint
Checkpoint: The Lost Dispatch
A guild messenger dropped a dispatch in the harbor. The ink still
reads Wpw mvbuk aol thw pu aol vsk spnoaovbzl. but the key was
lost at sea.
Build a code-cracker that tries every key, scores each try, and reports the best one. That's the whole chapter in one program.
Assignment
shift_text(text, shift) is ready for you.
score(text, words)returns how many words oftextare inwords(lowercase, punctuation.,!?stripped, repeats count).crack(secret, words)tries every key from 0 to 25. Keykdecodes withshift_text(secret, -k). Return a tuple(key, message)for the highest score. On a tie, keep the smallest key.- Print the result as
Key 7: ...(the key, a colon, then the message).
shift_text(text, shift) is ready for you.
score(text, words)returns how many words oftextare inwords(lowercase, punctuation.,!?stripped, repeats count).crack(secret, words)tries every key from 0 to 25. Keykdecodes withshift_text(secret, -k). Return a tuple(key, message)for the highest score. On a tie, keep the smallest key.- Print the result as
Key 7: ...(the key, a colon, then the message).
main.py Python sleeping
Press Run to try your code, then Check to test it.