Python has two types of loops: while loops and for loops. While loops execute a block of code repeatedly as long as a specified condition is true.
The condition is evaluated before each iteration of the loop. If the condition is true, the code block is executed. If the condition is false, the loop terminates. For example, the following code prints the numbers from 1 to 5: