As I mentioned in the pre-tutorial tutorial, loops tell the computer when to go and when to stop. In this way, they are sometimes called tools for "control flow".
Every form of program control has the same two parts: condition and action. If the condition is met, the action is taken; otherwise, the entire loop is passed over by the interpreter. The execution of the loop, whether once or more, is called iteration. It is important to remember that the condition is only evaluated at the beginning of each pass; changes in the middle or at the end will only effect the next cycle of the loop.
In Python, there are three kinds of loops: while, if, and for. Each of the three precedes the action to be taken and ends its condition with a colon (':').
When you use a loop, you must remember to indent the body of the loop. Unlike some languages, Python does not use braces to indicate the beginning and ending of a loop. It relies upon the indentation level of the line. There is no set amount that you must indent, though four spaces for each level is a popular convention. However, you must be consistent about how far you indent.
Any condition one might pose in Python must be represented in the appropriate way, otherwise the interpreter will not understand it. So, before discussing the format for loops, let's take a look at how to express comparison and equality in Python.
