Lua While Loop
# Lua while Loop
[ Lua Loops](#)
In the Lua programming language, a while loop statement repeatedly executes the loop body as long as the condition is true.
### Syntax
The syntax for a while loop in the Lua programming language:
while(condition)do statements end
**statements (loop body)** can be one or more statements, **condition** can be any expression, and the loop body is executed when **condition** is true.
The flowchart is as follows:

From the flowchart above, we can see that when the **condition** is false, the current loop is skipped, and script execution continues with the next statement.
### Example
The following example loops to output the value of a:
## Example
a=10
while( a <20)
do
print("a value is:", a)
a = a+1
end
Executing the above code, the output result is:
a value is:10 a value is:11 a value is:12 a value is:13 a value is:14 a value is:15 a value is:16 a value is:17 a value is:18 a value is:19
[ Lua Loops](#)
YouTip