Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

As you may have noticed, enciphering or deciphering a message means doing the same operation many times, once for each letter. You’d get tired of adding and subtracting by hand! When programming, it’s often impractical or impossible to type out every single operation. Instead, a programmer looks for the pattern in the repeated steps and describes that pattern once. One way to do that is with a loop, which iterates, or repeats, a block of code.

Python has two kinds of loops:

Each kind has its uses. We’ll soon see how loops let one short piece of code encipher or decipher a message of any length.