What is a Loop? Loop: Repeated execution of operations.
We will define a number of actions that we will perform a known number of times or until a certain condition is met.
For
As you can see, the loop printed from 0 to 5, five numbers, not including 5,
if we want the loop to also print the number 5, we will do the following:
The loop starts from 0, as long as we do not define an initial number.
The step the loop goes is 1, as long as we don't specify a number.
While
As long as the condition is met, the loop runs.
What happens if we remove the last line?
As you can see, we entered an infinite loop, we would like to avoid such cases.