The while loop

The while Statement
A while statement causes execution to loop over a set of statements until a condition evaluates to false

var counter = 5
while counter < 20 {
  print("The current value of counter is: \(counter)")

In the above example, a message is printed to the console while the variable counter is less than 20. The message contains a string with a text substitution. Specifically, the current value of the variable counter is included in the statement. The output will look similar to the following:

The current value of counter is 5
The current value of counter is 6
The current value of counter is 19

Note that the output stops at 19, and not 20. That's because the check is less than. To include 20, change the while condition to be:  while counter <=20