A while loop repeats a block as long as its condition is true. Python checks the condition before each pass, called an iteration. If it is true, the body runs, then Python goes back and checks again. When it is false, the loop ends and execution continues after the block. If the condition is false the very first time, the body never runs at all, so a while loop may run zero times.
Keep reading for free
Create a free StudyToCert account to read the rest of this lesson: 7 more sections, 6 key terms, a real-world example, an exam tip and self-check questions. Every lesson, lab and practice test is free with an account.