For Loop is a bit more complex command. You give it a variable name, its initial value, its end value, and a step (increment). It is the same as if you:
i
with an initial valuei <= end
i = i + step
at the end of WhileLet's write the same program as before, print first 5 numbers:
i
i
start value to 1i
end value to 5step
to 1i
in For bodyWe achieved the same result, but with a lot less code. Plus, it is more readable than before!
Nice job! This is the last Intermediate tutorial. You can continue learning with Advanced level tutorials.