4 Jump the Five: Working with dictionaries

“When I get up, nothing gets me down.”

--D. L. Roth

In an episode of the television show The Wire, drug dealers assume the police are intercepting their text messages. Whenever a phone number needs to be texted in the course of a criminal conspiracy, the dealers will obfuscate the number. They use an algorithm we’ll call “Jump the Five” because each number is changed to its mate on the opposite of a US telephone pad if you jump over the 5. In this exercise, we’ll discuss how to encrypt messages using this algorithm, and then we’ll see how to use it to decrypt the encrypted messages, you feel me?

If we start with the 1 button and jump across the 5, we get to 9. The 6 jumps the 5 to become ...

Get Tiny Python Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.