while Loops
April Speight · 2020
This chapter discusses how to create a while loop in Python. A while loop repeats (or iterates) all actions indented underneath the while loop so long as the defined condition is true. A break statement stops the while loop from looping even if the condition is true. A continue statement tells the while loop to return to the top of the loop at some other point in the code. To run a block of code once the condition for the while loop is no longer true, an else statement is included. For each iteration, Python checks whether the condition specified in the while loop is true. However, once the condition is false, the action inside the else statement occurs. The chapter also includes a project to create a Python program that randomly assigns players to a kickball team.